What's the standard pattern for ember-data validations? (invalid state, becameInvalid…)

前端 未结 5 745
囚心锁ツ
囚心锁ツ 2021-01-31 05:59

I\'ve kinda been struggling with this for some time; let\'s see if somebody can help me out.

Although it\'s not explicitly said in the Readme, ember-data provides somewh

5条回答
  •  盖世英雄少女心
    2021-01-31 06:31

    For some unknown reason, the record becomes part of the store default transaction. This code works for me:

    var transaction = App.store.transaction();
    var record = transaction.createRecord(App.Post);
    record.set('someProperty', 'invalid value');
    transaction.commit()
    
    record.set('someProperty', 'a valid value');
    App.store.commit(); // The record is created in backend
    

    The problem is that after the first failure, you must always use the App.store.commit() with the problems it has.

提交回复
热议问题