client/js/full-json.js
changeset 455 18b9be54174d
parent 444 19f0b7803aed
child 516 7d1d44b53af5
equal deleted inserted replaced
454:03e8815a012d 455:18b9be54174d
     6         _opts.http_method = 'PUT';
     6         _opts.http_method = 'PUT';
     7     }
     7     }
     8     var _load = function() {
     8     var _load = function() {
     9         _renkan.renderer.redrawActive = false;
     9         _renkan.renderer.redrawActive = false;
    10         _proj.set({
    10         _proj.set({
    11             loading_status : true
    11             loadingStatus : true
    12         });
    12         });
    13         Rkns.$.getJSON(_opts.url, function(_data) {
    13         Rkns.$.getJSON(_opts.url, function(_data) {
    14             _proj.set(_data, {
    14             _renkan.dataloader.load(_data);
    15                 validate : true
    15             _proj.set({
       
    16                 loadingStatus : false
    16             });
    17             });
    17             _proj.set({
    18             _proj.set({
    18                 loading_status : false
    19                 saveStatus : 0
    19             });
       
    20             _proj.set({
       
    21                 save_status : 0
       
    22             });
    20             });
    23             _renkan.renderer.redrawActive = true;
    21             _renkan.renderer.redrawActive = true;
    24             _renkan.renderer.fixSize();
    22             _renkan.renderer.fixSize();
    25         });
    23         });
    26     };
    24     };
    27     var _save = function() {
    25     var _save = function() {
    28         _proj.set({
    26         _proj.set({
    29             save_status : 2
    27             saveStatus : 2
    30         });
    28         });
    31         var _data = _proj.toJSON();
    29         var _data = _proj.toJSON();
    32         if (!_renkan.read_only) {
    30         if (!_renkan.read_only) {
    33             Rkns.$.ajax({
    31             Rkns.$.ajax({
    34                 type : _opts.http_method,
    32                 type : _opts.http_method,
    35                 url : _opts.url,
    33                 url : _opts.url,
    36                 contentType : "application/json",
    34                 contentType : "application/json",
    37                 data : JSON.stringify(_data),
    35                 data : JSON.stringify(_data),
    38                 success : function(data, textStatus, jqXHR) {
    36                 success : function(data, textStatus, jqXHR) {
    39                     _proj.set({
    37                     _proj.set({
    40                         save_status : 0
    38                         saveStatus : 0
    41                     });
    39                     });
    42                 }
    40                 }
    43             });
    41             });
    44         }
    42         }
    45 
    43 
    53         });
    51         });
    54         _thrSave();
    52         _thrSave();
    55     });
    53     });
    56     _proj.on("change", function() {
    54     _proj.on("change", function() {
    57         if (!(_proj.changedAttributes.length === 1 && _proj
    55         if (!(_proj.changedAttributes.length === 1 && _proj
    58                 .hasChanged('save_status'))) {
    56                 .hasChanged('saveStatus'))) {
    59             _thrSave();
    57             _thrSave();
    60         }
    58         }
    61     });
    59     });
    62 
    60 
    63     _load();
    61     _load();