Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Depending on your performance requirements use either .live('click', function(){}) instead of click(function(){}), or create a function inside of your users.js to make the bind and use a callback on jqgrid to run it.</p> <p>In users.js</p> <pre><code>$(function(){ $('#users').live('click', function(){ alert($("tr[aria-selected=true] td:first").html()) }) }) </code></pre> <p>Or in users.js:</p> <pre><code>function bindClickToRow(){ $(function(){ $('#users').click(function(){ alert($("tr[aria-selected=true] td:first").html()) }) }) } </code></pre> <p>Then use it in the callback of jqgrid ( I don't know how their API works and I couldn't find out quickly, but I am pretty sure a good grid plugin supports this, so consider this as pseudo code):</p> <pre><code>jQuery('table').jqgrid({ afterCreate: bindClickToRow }) </code></pre> <p>Hope this helps.</p> <p>The reason as far as I can see is that you are using 'click' to bind the click event of the to a function. But you are doing it when the actual itself does not exist yet. So you are basically telling jQuery, bind 'click' on all the s that exist right now. </p> <p>What would happen if you use 'live' though is the equivalent of telling jQuery to bind that function to a 'click' event on all current AND future 's that match your selector.</p> <p>The reason that the does not exist yet is because apparently jqgrid is loaded after the bind that is being called. Also, jqgrid probably creates new s regularly, long after the call to the 'click' bind. If you use 'live' jQuery will keep a lookout for all new s and will bind the callback function to them as soon as they are created.</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