我使用require.js和stickit进行模型绑定。 'change'事件工作正常,但如果我使用keyup进行聚焦,则checkBindings()函数不会触发。为什么会这样?
Stickit = require('stickit'),
ApplicantModel = require('application/models/applicantModel'),
template = _.template(tpl),
applicantView = Backbone.View.extend({
initialize: function() {
this.listenTo(this.model, 'change', this.checkBinding); //Change works fine, but keyup, focusout and other events do not fire
this.render();
},
checkBinding: function() {
console.log('Inside check binding functions');
var data = this.model.toJSON();
console.log($('#applicantInfoFirstName').val());
console.log($('#applicantInfoMiddleName').html(JSON.stringify(data.middleName)));
},
bindings: {
'#applicantInfoFirstName': 'firstName',
'#applicantInfoMiddleName': 'middleName',
'#applicantInfoLastName':'lastName'
},
render: function() {
console.log("Inside applicant view");
//Render application header
this.$el.html(template);
this.stickit();