Search code examples
jquerybackbone.js

JQuery Class Selector on Backbone View


My Backbone template has the .item class.

The View successfully displays the Model, I can see each .item on the web page.

However when I call

console.log($(".item"));

The resulting array is empty.

Is this normal with Backbone, or is my setup incorrect? Either way, how do I access the .items?


Solution

  • You use correct syntax in console log, but be sure you call it in correct way. Before BB view .render() output will be empty and after successful .render() you will get set of elements. So to make it work move console.log() call after render method