Guest User

Untitled

a guest
May 8th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. var captures = (function() {
  2.  
  3. var path = "/tsp/";
  4.  
  5. var comments = path + "delete/capture:captureId/comment:commentId"
  6.  
  7. // you return a closure object with key => values where the values are the functions and the keys are the names of the functions
  8. // 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 };
  9. // you can return objects to. here our are closing over some properties defined in your captures function encapsulated in new functions
  10. return {
  11. addComment: function(id, timestamp, text) {
  12. alert('add comment');
  13. },
  14.  
  15. deleteComment: function(captureId, commentId, success, error) {
  16. var url = comments.replace("captureId",captureId).replace("commentId",commentId);
  17. var post = {
  18. type:'POST',
  19. url: url,
  20. success: success,
  21. error: error
  22. };
  23. $.ajax(post);
  24. }
  25. };
  26.  
  27. })();
Advertisement
Add Comment
Please, Sign In to add comment