
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 0.92 KB | hits: 12 | expires: Never
var captures = (function() {
var path = "/tsp/";
var comments = path + "delete/capture:captureId/comment:commentId"
// you return a closure object with key => values where the values are the functions and the keys are the names of the functions
// everything in js is an object with a prototype. that prototype is defined as just a hash of keys and values {} var o = { foo: 1 };
// you can return objects to. here our are closing over some properties defined in your captures function encapsulated in new functions
return {
addComment: function(id, timestamp, text) {
alert('add comment');
},
deleteComment: function(captureId, commentId, success, error) {
var url = comments.replace("captureId",captureId).replace("commentId",commentId);
var post = {
type:'POST',
url: url,
success: success,
error: error
};
$.ajax(post);
}
};
})();