我正在使用 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();