Skip to content

Instantly share code, notes, and snippets.

@igormoochnick
Created August 21, 2012 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igormoochnick/3411363 to your computer and use it in GitHub Desktop.
Save igormoochnick/3411363 to your computer and use it in GitHub Desktop.
jinx - using generated data models with the REST service
this.registerOnServer = function () {
$.post("/api/ToDo", getDataModel());
};
this.removeFromServer = function () {
$.ajax({
type: "DELETE",
url: "/api/ToDo/" + self.guid
});
};
this.updateOnServer = function() {
$.ajax({
type: "PUT",
url: "/api/ToDo/" + self.guid,
data: getDataModel()
});
};
function getDataModel() {
var item = new ToDoItem();
item.guid = self.guid;
item.title = self.title();
item.completed = self.completed();
return item;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment