optimize top btn

This commit is contained in:
OttoMao
2015-08-07 14:27:57 +08:00
parent 39ae0f4648
commit ae070c90ab
11 changed files with 214 additions and 71 deletions

View File

@@ -1,3 +1,7 @@
function fetchConfig(cb){
return $.getJSON("/getMapConfig",cb);
}
function init(React){
var MapList = React.createClass({displayName: "MapList",
getInitialState:function(){
@@ -19,7 +23,6 @@ function init(React){
ruleList: newState
});
}
},
removeRecord:function(index){
@@ -52,7 +55,7 @@ function init(React){
},
componentDidMount :function(){
var self = this;
$.getJSON("/getMapConfig",function(data){
fetchConfig(function(data){
self.setState({
ruleList : data
});
@@ -60,8 +63,8 @@ function init(React){
},
componentDidUpdate:function(){
var self = this;
//sync config
//upload config to server
var currentList = self.state.ruleList;
$.ajax({
method : "POST",
@@ -71,10 +74,13 @@ function init(React){
dataType : "json",
success :function(res){}
});
self.props.onChange && self.props.onChange(self.state.ruleList);
}
});
return MapList;
}
module.exports.init = init;
module.exports.init = init;
module.exports.fetchConfig = fetchConfig;