javascript - Backbone: How to prevent overriding jQuery Ajax methods by Backbone Ajax functions? -


very interesting situation!

the code below represents order entry. before saving user should calc order total clicking on #calctotal button , clicks on #saveorder button.

the problem if user launches saveorder function 1 time ajax method in calctotal function call model.save in saveorder function!

i think this.model.save function override backbone model functions ajax request execute actions in model.save.

how should prevent behaviour?

events: {      'click #calctotal': 'calctotal',      'click #saveorder': 'saveorder' }, calctotal: function() {     this.model.set( $('form').serializejson() );     var = this;      $.ajax({         url: 'api/order/calctotal',         type: 'get',         data: this.model.tojson(),         datatype: 'json',         success: function( result ) {             that.model.set({                 'total': result.total             });             that.rendertotal();         }     }); },  saveorder: function() {     var = this;      this.model.save({         success: function() {             console.log('check');         }     }); }, 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -