Note that there are some explanatory texts on larger screens.

plurals
  1. POBizzare Jquery (Mobile) errors when using .find() or selecting a checkbox?
    text
    copied!<p>So eh, while making a phone App with phonegap (and using jsconsole.com for debugging) I ran into this bizzare problem when I tried to access a input checkbox and 'check' it with JQuery depending on some scenarios. The problem is a lot more mysterious than that however...</p> <p>Basic html is as such (inside a jqm-page), which runs from Adnroid Emulator:</p> <pre><code>&lt;div data-role="controlgroup" data-type="horizontal" id="settings_bar"&gt; &lt;input type="checkbox" name="isAFav" id="isAFav"&gt; &lt;label for="isAFav"&gt;Favourite&lt;/label&gt; &lt;a href="#" data-role="button" data-icon="delete" data-iconpos="right" onclick="app.delete()"&gt;Delete&lt;/a&gt; &lt;/div&gt; </code></pre> <p>When the page loads to display content I want to adjust the displayed info with a function which looks something like this:</p> <pre><code>if(isAFav){ // &lt;-local variable from my runtime - it's valid try{ var fav = $('#settings_bar').find("#isAFav"); fav.attr('checked', 'true'); fav.button('refresh'); }catch(Err){ console.log(err.message()); } } </code></pre> <p>The cryptic error that it throws is as such:</p> <blockquote> <p>Accessing selectionEnd on an input element that cannot have a selection.</p> </blockquote> <p>The exact same thing happens for a multitude of:</p> <pre><code>$("#route_settings_bar").children('input'); $('input[name="isAFav"]'); </code></pre> <p>I don't know what the hell is going wrong. I'm using the latest Jquery +mobile (1.9.1 &amp; 1.3.0 respectively).</p> <p>To add to the confusion, I previously named the form/id of the input as 'fav' and when I ran the corresponding code:</p> <pre><code>$('input[name="fav"]'); $("#route_settings_bar").children('input[name="fav"]'); //or this </code></pre> <p>we get this: <img src="https://i.stack.imgur.com/gH2gM.png" alt="enter image description here"></p> <p>To me this looks like JqueryMobile code...what the %&amp;^*? If anyone has any tips or suggestions, please help! Thanks!</p> <p>P.S. I'm using a different jsconsole ID now.</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