Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery not functioning without document.ready on a cfm page
    text
    copied!<p>I'm pretty new to jQuery, and I am converting a page from "regular" javascript to jQuery on a coldfusion page. The page is driven off a stored procedure, which, based on it's result sets, changes the page and number of input fields. On my page, the input tags look like this.</p> <pre><code>&lt;cfinput name="#trim(characteristic_id)#_fund" id="#trim(characteristic_id)#_fund" value="#fund#" size="11" onFocus="getCurrentValue(this)" onblur="checkChange(this,'c')"&gt; &lt;cfinput name="#trim(characteristic_id)#_benchmark" id="#trim(characteristic_id)#_benchmark" value="#benchmark#" size="11" onFocus="getCurrentValue(this)" onblur="checkChange(this,'c')"&gt; </code></pre> <p>The <code>onFocus</code> event just saves the current value, and the <code>onBlur</code> event checks to see if the value has changed, and if it has save it in a array for further processing.</p> <p>Personally, I feel like jQuery is suited very well for this kind of processing, and it is on of the main reason I am trying it. </p> <p>To my issue. Right now I am replacing the <code>onFocus</code> event handler with:</p> <pre><code>$("input").focus(function(){ alert($(this).val()); }); </code></pre> <p>simple, but when I try i, nothing happens, no javascript errors, nothing. Nothing happens at all. So, all of the other jQuery code that I have written, I have used <code>$(document).ready...</code>, and when I used that, it worked fine. From what I've read, the UI is rendered before the DOM is ready, but to compound that issue the coldfusion is running prior to everything else.</p> <p>My question is this; Do I have to put all of my jQuery code inside the <code>$(document).ready...</code> function or is there another way around it.</p> <p>Thanks in advance.</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