client/js/full-json.js
changeset 443 4c7ab16e5845
parent 414 276042cb477c
child 444 19f0b7803aed
equal deleted inserted replaced
442:adb907bba956 443:4c7ab16e5845
     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             _proj.set(_data, {
    15                 validate : true
    15                 validate : true
    16             });
    16             });
    17             _proj.set({
    17             _proj.set({
    18                 loading_status : false
    18                 loadingStatus : false
    19             });
    19             });
    20             _proj.set({
    20             _proj.set({
    21                 save_status : 0
    21                 saveStatus : 0
    22             });
    22             });
    23             _renkan.renderer.redrawActive = true;
    23             _renkan.renderer.redrawActive = true;
    24             _renkan.renderer.fixSize();
    24             _renkan.renderer.fixSize();
    25         });
    25         });
    26     };
    26     };
    27     var _save = function() {
    27     var _save = function() {
    28         _proj.set({
    28         _proj.set({
    29             save_status : 2
    29             saveStatus : 2
    30         });
    30         });
    31         var _data = _proj.toJSON();
    31         var _data = _proj.toJSON();
    32         if (!_renkan.read_only) {
    32         if (!_renkan.read_only) {
    33             Rkns.$.ajax({
    33             Rkns.$.ajax({
    34                 type : _opts.http_method,
    34                 type : _opts.http_method,
    35                 url : _opts.url,
    35                 url : _opts.url,
    36                 contentType : "application/json",
    36                 contentType : "application/json",
    37                 data : JSON.stringify(_data),
    37                 data : JSON.stringify(_data),
    38                 success : function(data, textStatus, jqXHR) {
    38                 success : function(data, textStatus, jqXHR) {
    39                     _proj.set({
    39                     _proj.set({
    40                         save_status : 0
    40                         saveStatus : 0
    41                     });
    41                     });
    42                 }
    42                 }
    43             });
    43             });
    44         }
    44         }
    45 
    45 
    53         });
    53         });
    54         _thrSave();
    54         _thrSave();
    55     });
    55     });
    56     _proj.on("change", function() {
    56     _proj.on("change", function() {
    57         if (!(_proj.changedAttributes.length === 1 && _proj
    57         if (!(_proj.changedAttributes.length === 1 && _proj
    58                 .hasChanged('save_status'))) {
    58                 .hasChanged('saveStatus'))) {
    59             _thrSave();
    59             _thrSave();
    60         }
    60         }
    61     });
    61     });
    62 
    62 
    63     _load();
    63     _load();