javascript - Backbone.js event handler not working -


i trying backbone.js examples given here , tried writing code on own.

for reason event handler have attached event 'click p' not working. why 'highlight' function not executing when paragraph tag clicked?

var itemview = backbone.view.extend({     tagname : 'p',      events: {         'click p': 'highlight'     },      initialize: function(){         console.log("an object of itemview created");         _.bindall(this, 'render', 'highlight');          this.render();        },      render: function(){         this.$el.text(this.model.get('content'));         $('body').append(this.$el);         return this;     },      highlight: function(){         console.log('clicked');     }  }); 

this event targeting <p> element inside root element. not targeting root element, if root element <p> element.

try:

events: {   'click': 'highlight' } 

to target root element.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -