简体   繁体   English

在骨干网中绑定模型时,不会触发keyup事件

[英]On keyup event not firing when binding a model in backbone

I am using require.js and stickit for model binding. 我正在使用require.js和stickit进行模型绑定。 'change' event works fine, but if i use keyup for focusout the checkBindings() function does not fire. 'change'事件工作正常,但是如果我使用keyup进行焦点输出,则checkBindings()函数不会触发。 Why is this so? 为什么会这样呢?

        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();

The events are specific to changes in the model. 这些事件特定于模型中的更改。 The list of events are here 活动清单在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM