The problem with that is that right after I call that function, the next line I call some UI binding, which fail, unless I put in a time delay.
So synchronous is not a truly synchronous call.
For a sanity check, I did the following:
ko.applyBindings(myApp.myVM);
window.setTimeout("GetElementCounts()", 500);
window.setTimeout("FormatElements()", 500);
The methods I call
function GetElementCounts() {
alert("colapsibles:" + $(".collapsibleDiv").length
+ "\nCheck boxes:" + $(":checkbox").length
+ "\nGroups:" + $(".checkbox-controlgroup").length
+ "\nmychild cases:" + $(".mychild").length
+ "\nchild divs:" + $(".mychild div").length
);
}
function FormatElements() {
$(".collapsibleDiv").collapsible();
$(".mychild + div").collapsible();
$(':checkbox').checkboxradio();
$(".checkbox-controlgroup").controlgroup();
}
All of the $('') calls refer to elements that are in my template. So the problem is that when I call the applyBindings, it may be up to a half a second before I can allow the rest of my code to execute, else, I risk my formatters failing.
I haven't tested this on a low bandwidth, which a half second may not be large enough.
For curiosity sake, these jQuery calls are to overcome a known jQueryMobile issue with knockout.js.