Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery mobile with knockout checkbox not working
    text
    copied!<p>I have a checkbox that needs another checkbox selected before its legal to select it. If selecting the checkbox is illegal I want to unselect it. The code goes like this: </p> <pre><code>if (self.Advances()[i].Bought()) { break; } else { advance.Bying(false); $("#" + advance.Id).checkboxradio('refresh'); return; } </code></pre> <p>Inspecting the knockout object and the DOM both the value and the checkbox is correctly not set when the else above hits. The GFX is however not uppdated so the checkbox is still visualy checked. </p> <p>After experimenting a bit I found that introducing a javascript error in the refresh line actually led to everything working as expected (wich was unexpected) IE the following works: </p> <pre><code>if (self.Advances()[i].Bought()) { break; } else { advance.Bying(false); //parent is not a check box, so error is thrown. $("#" + advance.Id).parent().checkboxradio('refresh'); return; } </code></pre> <p>This led me to belive that JQM is triggered in the wrong order (IE the refresh I manually do above is triggered BEFORE the refresh from the mouse event)</p> <p>So I ended up with the following (working but inelegant) solution using setTimeout: </p> <pre><code>if (self.Advances()[i].Bought()) { break; } else { setTimeout(function () { advance.Bying(false); $("#" + advance.Id).checkboxradio('refresh'); }, 250); return; } </code></pre> <p>My question is there anyway I can force JQM to do the refreshes in the right order? Or is this a bug in JQM or is there something I don't understand about how JQM works? </p> <p>Edit: The whole code (and site) can be found on civ.testmaskin.com</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload