Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Created August 13, 2015 18:37
Show Gist options
  • Save LinzardMac/29151266367250bf4447 to your computer and use it in GitHub Desktop.
Save LinzardMac/29151266367250bf4447 to your computer and use it in GitHub Desktop.
/* backbone functions for views */
render: function() {
var compat = this.model.get('compat');
if ( ! compat || ! compat.item ) {
return;
}
this.views.detach();
this.$el.html( compat.item );
this.views.render();
return this;
},
save: function( event ) {
var data = {};
if ( event ) {
event.preventDefault();
}
_.each( this.$el.serializeArray(), function( pair ) {
data[ pair.name ] = pair.value;
});
this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
},
postSave: function() {
this.controller.trigger( 'attachment:compat:ready', ['ready'] );
}
/* basic .on() test code */
jQuery(document).on('click', 'a', function(event) {
event.preventDefault()
alert('hey');
var input = jQuery('input');
input.css('background-color' , 'red');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment