Trigger backbone.js change when value doesn't change

后端 未结 2 609
鱼传尺愫
鱼传尺愫 2021-02-12 21:59

It\'s a known feature of backbone.js that when you set data that hasn\'t changed it won\'t fire the change event, nor will it go through validations. I however need the change e

相关标签:
2条回答
  • 2021-02-12 22:30

    Manually trigger the change event:

    t.model.trigger('change', t.model);
    

    or

    t.model.trigger('change:fieldErrors', t.model, newFieldErrorsValue);
    
    0 讨论(0)
  • 2021-02-12 22:31
    this.model.set({fieldErrors: JSONResponse}, {silent:true});
    this.model.trigger('change:fieldErrors');
    

    see this conversation:

    Can I force an update to a model's attribute to register as a change even if it isn't?

    0 讨论(0)
提交回复
热议问题