Created
          July 17, 2013 15:41 
        
      - 
      
- 
        Save dylants/6021757 to your computer and use it in GitHub Desktop. 
    Backbone sync success and failure
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | return Backbone.View.extend({ | |
| ... | |
| events: { | |
| "click #submit-button": "submit" | |
| }, | |
| initialize: function() { | |
| this.model.on( "sync", this.syncSuccess, this ); | |
| this.model.on( "error", this.syncFailed, this ); | |
| }, | |
| ... | |
| submit: function(ev) { | |
| ... | |
| this.model.save(); | |
| }, | |
| syncSuccess: function() { | |
| // this method is called after the save is successful | |
| ... | |
| }, | |
| syncFailed: function(model, response, options) { | |
| // this method is called after the save failed | |
| ... | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment