Forgive me if this question has been asked previously, as my search attempts have been unsuccessful in finding a solution. Despite consulting the knockout documentation, I still struggle to articulate my issue effectively for searching.
My situation involves 3 select lists and a Knockout view model. When a value is selected in the first list, it updates an observable in the view model. Subsequently, I need to initiate an ajax post request to send that value to the server and receive a list of values back, which will then populate an observable array in the view model, updating the other two lists accordingly.
While I am comfortable with managing observables, my dilemma lies in determining how and where to trigger the ajax call.
If I trigger it upon the change event of the first select, it often leads to a race condition where the call occurs before the view model update is complete. I could bypass using the observable altogether, but that deviates from typical Knockout practices.
An alternate approach using a custom binding for data retrieval results in redundant ajax calls, and directly embedding the retrieval within a function is impractical due to its asynchronous nature and repeated invocation.
It seems necessary to establish a mechanism that monitors an observable and initiates an ajax call without any visible interaction.
Any assistance on this matter would be greatly appreciated.