Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment