Joined August 2014
·

vayu

india
·
·

Posted to Using Backbone's new `listenTo` over 1 year ago

this.listenTo( this.collection, 'add', this.renderBook );

renderBook: function( item ) {
console.log("this is renderBook");
var bookView = new app.BookView({
model: item
});
this.$el.append( bookView.render().el );
},

events:{
'click #add':'addBook'
},
addBook: function( e ) {
console.log("This is event mathod");
e.preventDefault();
var formData = {};
$( '#addBook div' ).children( 'input' ).each( function( i, el ) {
if( $( el ).val() != '' ){
formData[ el.id ] = $( el ).val();
}
});
this.collection.add( new app.Book( formData ) );
console.log(JSON.stringify(formData));
},

this code is not working......

Achievements
1 Karma
0 Total ProTip Views