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

Commenting out JMVC cookbook fixture makes Controller call fail

$
0
0
Just starting to look into JMVC as an alternative to GWT and what I did is just follow the sample app http://javascriptmvc.com/docs.html#!creating and replace the fixture for the create action by an actual http call to a rest service, my project is called Dummy and the model is called Message:

a) In dummy/message/create/create.html I commented out the fixture as follows:
  1. steal('dummy/message/create',/*'dummy/fixtures',*/function(){
b) In dummy/message/create/create.js I added an error callback function:
  1. submit : function(el, ev){
  2. ev.preventDefault();
  3. this.element.find('[type=submit]').val('Creating...')
  4. new Dummy.Models.Message(el.formParams()).save(this.callback('saved'),this.callback('error'));
  5. },
  6. saved : function(){
  7. this.element.find('[type=submit]').val('Create');
  8. this.element[0].reset()
  9. },
  10. error : function(request){
  11. alert(request.status);
  12. }
c) Changed the model dummy/models/message.js
  1. $.Model('Dummy.Models.Message',
  2. /* @Static */
  3. {
  4. findAll: "GET http://localhost/services/messages.json",
  5.    findOne : "GET http://localhost/services/messages/{id}.json", 
  6.    create : "POST http://localhost/services/messages.json",
  7.   update : "PUT http://localhost/services/messages/{id}.json",
  8.    destroy : "DELETE http://localhost/services/messages/{id}.json"
  9. },
The strange thing is that even if it goes to the error callback when it calls alert(request.status); returns a 200 status.

Any idea what Am I doing wrong?

Thanks,

Johann



Viewing all articles
Browse latest Browse all 3491

Trending Articles