Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery is not able to 'connect' with the elements on my server generated webpage
    text
    copied!<p>I'm trying to use jQuery functionality in Software AG webMethods IDE, which generates pages on its own .. Basically, I'm giving jQuery's functions a server-generated element ID, but jQuery is unable to read it's value, or write a value to it, or do anything with it ..</p> <p>Here's the code I'm using:</p> <pre><code>if(jQuery.isNumeric(jQuery(CAF.model("#{activePageBean.clientIds['txtInput']}").id).val())) { alert("its a number"); } else { alert("its not a number"); } </code></pre> <p>txtInput is a normal input text field, and the above code is assigned to a button ... And no matter what is put into the text field, I always get the "its not a number" alert ..</p> <p>Also, if I use this code instead ..</p> <pre><code>alert(jQuery(CAF.model("#{activePageBean.clientIds['txtInput']}").id).val()); </code></pre> <p>... I always get an alert saying "undefined" (without the double quotes) ..</p> <p>The expression returning the text field's ID is:</p> <pre><code>CAF.model("#{activePageBean.clientIds['txtInput']}").id </code></pre> <p>.. and this is:</p> <pre><code>jsfwmp147312:defaultForm:txtInput </code></pre> <p>If I instead run this webMethods built-in function to get the value:</p> <pre><code>CAF.model("#{activePageBean.clientIds['txtInput']}").getValue(); </code></pre> <p>It does return the value currently in the text field ..</p> <p>So basically for some reason jQuery's functions are unable to 'connect' with the page's elements ..</p> <p>How do I diagnose/resolve this ?</p> <p><strong>EDIT:</strong></p> <p><em>More information:</em></p> <p>If I try the following code ...</p> <pre><code>var myId = "jsfwmp147312:defaultForm:txtInput"; var element = document.getElementById(myId); alert(element.value + ""); </code></pre> <p>.. I get the string text field's string value in the alert fine, no problems ... But if I try this ...</p> <pre><code>var myId = "jsfwmp147312:defaultForm:txtInput"; var val2 = jQuery(myId).val(); alert(val2); </code></pre> <p>... I get an alert with the message "undefined" (without the double quotes) ..</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