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:
- steal('dummy/message/create',/*'dummy/fixtures',*/function(){
b) In dummy/message/create/create.js I added an error callback function:
- submit : function(el, ev){
- ev.preventDefault();
- this.element.find('[type=submit]').val('Creating...')
- new Dummy.Models.Message(el.formParams()).save(this.callback('saved'),this.callback('error'));
- },
- saved : function(){
- this.element.find('[type=submit]').val('Create');
- this.element[0].reset()
- },
- error : function(request){
- alert(request.status);
- }
c) Changed the model dummy/models/message.js
- $.Model('Dummy.Models.Message',
- /* @Static */
- {
- findAll: "GET http://localhost/services/messages.json",
- findOne : "GET http://localhost/services/messages/{id}.json",
- create : "POST http://localhost/services/messages.json",
- update : "PUT http://localhost/services/messages/{id}.json",
- destroy : "DELETE http://localhost/services/messages/{id}.json"
- },
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