In Backbone.js I am trying to use a variable as a selector to bind to an event like this:
events: function() {
var _events = {};
_events["click " + "#plus-" + this.options.count] = "add";
return _events;
}
Some (or more than one) thing must be wrong because Backbone seems to ignore it.
Most examples I’ve seen here use class and not id selectors. Is there a reason for that?
Thanks in advance
I have to say that I don’t understand this dynamic events declaration need. But I suppose you have your reasons.
Any how I’ve come up with a working solution that looks like this:
Check the working jsFiddel
So, either I’m missing something or the issue is somewhere else.
About using
classoridin your events css selector it is just up to you.