Tuesday, 27 August 2013

Saved to Server, Want it to Update JSON File

Saved to Server, Want it to Update JSON File

Using BackgridJS.com for this project, and I want to be able to update
text in a cell, and have it automatically update the corresponding JSON
file. (The cell's original text is pulled from a JSON file"
From the BackgridJS website:
How do I save my row changes to the server immediately?
var MyModel = Backbone.Model.extend({
initialize: function () {
Backbone.Model.prototype.initialize.apply(this, arguments);
this.on("change", function (model, options) {
if (options && options.save === false) return;
model.save();
});
}
});
This works on my site, because when I update the cell, it POSTs
successfully. It posts like this:
city: "Example"
country: "Example"
type: "Example"
url: "http://example.com"
year: "Example"
I am using MAMP. How would I be able to update the JSON file when I update
the cell?

No comments:

Post a Comment