I have upgraded my web application from Backbone 0.9.10 to Backbone 1.2.1, and everything is great with one exception. See the code below:
define( ['underscore', 'backbone', 'text!templates/myResults.html'], function (_, Backbone, Template) {
var myView = Backbone.View.extend({
el: '#myResults',
initialize: function (options) {
this.targetLoc = options.targetLoc;
},
events: function() {
var _events = {};
_events ['show ' + this.targetLoc + ' a'] = 'tabClicked';
return _events;
},
tabClicked: function (e) {
....stuff....
}
template: _.template(Template),
render: function() {
var outputHTML = this.template({model: this.model.toJSON()});
this.$el.append(outputHTML);
return this;
}
});
});
return myView;
Before I upgraded Backbone, my tabClicked
event fired without issue. Now it doesn't fire, and when I console.log(this.targetLoc);
in the events
function it says that this.targetLoc
is undefined.
I even tried adding:
this.events['show ' + this.targetLoc + ' a'] = 'tabClicked';
to the initialize
function to no avail.
This application is using:
- jQuery 1.9.1
- jQuery UI 1.10.3
- Underscore 1.8.3
- Bootstrap JS 2.3.1
- Require 2.1.5
- Backbone 1.2.1 (formerly 0.9.10)
Obviously something changed from 0.9 to 1.2 of Backbone, any ideas on how I can fix my problem?