Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it is important to point out that there are times when this will not work properly (as of jQuery 1.7):</p> <pre><code>$('#element').html(some_really_large_value); console.log($('#element').html()); </code></pre> <p>There are times when the DOM updates do not block function execution, and what will appear in console will be the previous content of #element.</p> <p>If this is the case in the above example, then even adding a callback to $.dateSelectBoxes may not solve the problem. If this still does not return the correct value:</p> <pre><code>$.dateSelectBoxes( ... $('#release_month') ... , function(){ console.log($('#release_month').val()); }); </code></pre> <p>Then the only solution I know of is to add a race condition:</p> <pre><code>$.dateSelectBoxes( ... $('#release_month') ... , function(){ setTimeout(function(){ console.log($('#release_month').val()) }, 100); }); </code></pre> <p>[UPDATE]</p> <p>I'm recently finding out that the problem here is not that the .html() method isn't blocking function execution, but that the browser is grouping DOM updates by function scope (or something like that, am a bit fuzzy on the details). </p> <p>This means that jQuery DOM updates with .html() and .val(), do block, but they only block as far as scheduling the DOM update with the browser. Thus even wrapping the DOM read in a setTimeout( fn, 1) will solve the problem.</p> <p>BTW, this is exactly the kind of thing <a href="https://github.com/bishopZ/Frame.js" rel="nofollow">Frame.js</a> was designed to solve.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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