Skip to content

Instantly share code, notes, and snippets.

@rapzo
Created August 13, 2013 22:56
Show Gist options
  • Save rapzo/6226518 to your computer and use it in GitHub Desktop.
Save rapzo/6226518 to your computer and use it in GitHub Desktop.
var FormView = Backbone.View.extend({
el: '#form',
events: {
// Fired automatically when a file-type input is detected with a
// non-blank value. You can use this hook to implement a handler that
// will deal with those non-blank file inputs. Returning false will
// disallow standard form submission.
'ajax:aborted:file' : 'ajaxAbortedFile',
// Fired when there are required inputs which have been left blank.
// You can use this handler to deal with those blank required inputs.
// Returning false will submit the form anyway.
'ajax:aborted:required' : 'ajaxAbortedRequired',
// First event fired for any remote enabled form. Stopping this event
// will cancel the ajax request
'ajax:before' : 'ajaxBefore',
// Fired before the ajax request is sent. Stopping this event will
// cancel the ajax request. Commonly used to customize certain request
// headers
'ajax:beforeSend' : 'ajaxBeforeSend',
// Fired after completion, if the HTTP response was a success
'ajax:success' : 'ajaxSuccess',
// Fired after completion, if the server returned an error
'ajax:error' : 'ajaxError',
// Fired after the request has been completed, no matter what outcome
'ajax:complete' : 'ajaxComplete'
},
ajaxAbortedFile: function(e, elements){
},
ajaxAbortedRequired: function(e, elements){
},
ajaxBefore: function(e){
},
ajaxBeforeSend: function(e, xhr, settings){
},
ajaxSuccess: function(e, data, status, xhr){
},
ajaxError: function(e, xhr, status, error){
},
ajaxComplete: function(e, xhr, status){
}
});
$(function(){
window.view = new FormView();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment