Updating Bindings Problem

23 views
Skip to first unread message

mick...@gmail.com

unread,
May 1, 2013, 11:59:42 AM5/1/13
to knock...@googlegroups.com
I have a label that displays status... it starts out "searching...", next it should display "rendering...", and finally, "Matched n results".

It works find except after updating the observable that changes the status to searching, the label does not change and jumps directly to Matched results. It takes about 5 seconds to render the results, and even though I update the observable right before setting the observable array to my data... the label doesn't update.  When I place an alert box between the status change and the setting of the data, the label changes.

Is there a way to force knockout to handle its existing events (show the new value of the bound element) before continuing to render what's about to come (when I apply the newly returned data to the observableArray - which causes 5 seconds of processing)?

Thanks,
Mick

Casey Corcoran

unread,
May 1, 2013, 3:37:59 PM5/1/13
to knock...@googlegroups.com
The way you've worded your question is a bit confusing… 

Sounds like you've got a blocking script (for 5 secs, wow!) and you're not seeing the observable update because of it. So I would probably do something like:

statusLabel("searching…");
// Data is returned from server
statusLabel("rendering…");
setTimeout( processStuff, 0 );


-- 
Casey Corcoran
Sent with Sparrow

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mick Owen

unread,
May 1, 2013, 7:11:48 PM5/1/13
to knock...@googlegroups.com
Thank you Casey, that worked... although I was hoping for a way to tell knockout to process the bindings that need updating before continuing...
Reply all
Reply to author
Forward
0 new messages