Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Fixture request does not work why ?

$
0
0
Hi I am working on a project that use fixture, the problem is when I create a new element with the model create function that use fixture to simulate  ajax. Nothing happens on the screen eventough I have followed all the instructions to make working.

My model :

  1. $.Model('Comment', {
  2. findAll : 'GET /moment/{momentId}/comments',
  3.     create :  function(opt, success, error){
  4.         console.log('comment create');
  5.         return $.ajax({
  6.             url: '/moment/{momentId}/comment',
  7. fixture: '//fixture/json/moments_list_1.json',
  8.             type: 'post',
  9.             success: success,
  10.             error: error
  11.         });
  12.     },
  13.     update :  function(opt, success, error){
  14.         console.log('comment update');
  15.         return $.ajax({
  16.             url: '/moment/{momentId}/comment/{commentId}',
  17.             type: 'put',
  18.             success: success,
  19.             error: error
  20.         });
  21.     },
  22.     destroy : 'DELETE /moment/{momentId}/comment/{commentId}'
  23. });
  24. My function that call the model :

  25. '#comment_field keypress' : function(el, ev){
  26. if (ev.which == 13) {
  27. Comment.create({
  28. momentId : $("#comment_id").val(),
  29. comment :  el.val()
  30. },
  31. function(newAttrs) {
  32. console.log(newAttrs);
  33. });
  34. el.val('');
  35. }
  36. }
  37. and my fixture request :

  38. $.fixture("/moment/{momentId}/comment","/resources/js/fixture/json/moments_list_1.json");                       // comment
  39. $.ajax({type: "post", 
  40.        url: "/moment/{momentId}/comment", 
  41.        fixture: "/resources/js/fixture/json/moments_list_1.json"
  42.   });

Viewing all articles
Browse latest Browse all 3491

Trending Articles