关于在骨干中绑定模型时未触发的键盘事件

时间:2014-06-17 06:41:52

标签: javascript backbone.js requirejs backbone-stickit

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

1 个答案:

答案 0 :(得分:0)

事件特定于模型中的更改。事件列表为here