【问题标题】:On keyup event not firing when binding a model in backbone在主干中绑定模型时未触发 keyup 事件
【发布时间】:2014-06-17 06:41:52
【问题描述】:

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

【问题讨论】:

    标签: javascript backbone.js requirejs backbone-stickit


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多