How to force an event to update binding to `store.first()`?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to force an event to update binding to `store.first()`?



I have a label binding to MyStore.first.my_name and when .load() is called the bindings update correctly.


MyStore.first.my_name


.load()



Now I update another field that represents a numeric version of my_name and can not get the binding to get notified on reload(). I have marked the binding as deep as well and that does not seem to make any difference.


my_name


reload()


deep



Here is what I have tried and the outcome is the same in all cases, the binding to MyStore.first.my_name never gets updated.


MyStore.first.my_name


var store = this.getViewModel().get('MyStore');
store.first().set('my_id', newValue);
store.sync(); // I also tried autoSync == true same issue
store.reload();



I also tried:


var store = this.getViewModel().get('MyStore');
var sc = store.first();
sc.set('my_id', newValue);
store.sync();
store.reload();



as well as going to the extreme of:


var store = this.getViewModel().get('MyStore');
var sc = store.first();
sc.set('my_id', newValue);
store.sync();
var id = sc.get('id');
store.removeAll(true); // removes from store without deleting them on server
store.load( url: '/api/service/' + id );


sync()




1 Answer
1



Here is how I got it to work:



I disabled autoSync on the store.


autoSync



I called the sync() with a success callback to then trigger the reload()


sync()


success


reload()


sync(success:function(batch,options)
store.reload();
);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered