ajax - KnockoutJs - How to "synchronize" subscriptions and click event? -


simple situation. have form textboxes, bound observables. observables has subscriptions logic (server validation, whatever, ajax call).

there button on form "save data" logic. data should saved when callbacks finished.

subscribtions fired when value changed, on focus lost, not on every change.

now can type textbox click on save button. happens? click event called, , data saved. faster subscribtion event fired , server returns data.

how "synchronize" click "done" promise of subscriptions? need prevent save data before done. there no relation between subscription of textbox value , button. async, can't call "wait function" in click event. other problem should subcription fired later click event.

any solution this?

add variable manage button state -

<button data-bind="disable: serversidecheckinprogress">save data</button> 

within ajax call -

//declare serversidecheckinprogress false on init  savedata = function(){   serversidecheckinprogress(true);   $.ajax({     url: "test.html",     context: document.body   }).done(function() {     serversidecheckinprogress(false);   }); } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -