Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
this.$(someElement) Doesn't Work #1038
Somewhere between 0.5 and 0.9 Backbone changed the definition of the delegator (this.$()) from:
return $(selector, this.el);
Now as the jQuery site itself says:
"Selector context is implemented with the .find() method; therefore, $('li.item-ii').find('li') is equivalent to $('li', 'li.item-ii')."
so that change should be perfectly safe, right? Well, it is, but only:
If however you try to do:
Now similarly, in Backbone it makes no sense to do this.$(elem) when you can just as easily do $(elem) (and the latter works). But sometimes you might have a variable that could be a string or could be an element ... or you might just have some legacy code that does the former, and it's a pain to change.
All of this can be solved ... well in two ways (that I see):