Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Is <code>"#list"</code> the element that contains the dynamically generated <code>&lt;a&gt;</code> elements? </p> <p>If so, use <a href="http://api.jquery.com/delegate/" rel="nofollow">jQuery's <code>.delegate()</code> method</a> to place a handler on it, so any of the <code>'a[rel*=Tab]'</code> elements that are clicked within it will fire the handler.</p> <pre><code>jQuery("#list").delegate( 'a[rel*=Tab]', 'click', function() { //... }); </code></pre> <p>Any <code>'a[rel*=Tab]'</code> elements that are added to <code>#list</code> will automatically work. If <code>#list</code> is not the container, then use the correct selector for the container.</p> <hr> <p><strong>EDIT:</strong> While the <code>.delegate()</code> method above is (in my opinion) the best approach, if you did want to assign individual <code>click</code> handlers to only the new elements as you create them, you would need to call the same <code>.click()</code> method against the specific new elements.</p> <p>So if you create a new <code>&lt;a&gt;</code> after the page loads, you'd do something like this:</p> <pre><code>var $newA = $('&lt;a rel="someTab"&gt;some text&lt;/a&gt;'); // Assign click handler to only the newly created element $newA.click(function(e) { e.preventDefault(); //then I do some stuff to open it in jq ui tab }); $newA.appendTo('#list'); </code></pre> <p>Of course this is not your exact code, but shows how you can create a new element, store a reference to it, and assign the <code>click</code> handler to only that element.</p> <p>Or if you're creating a larger structure where the <code>&lt;a&gt;</code> is nested, you can do the same thing, but do a <code>.find()</code> to get the <code>&lt;a&gt;</code> inside the structure, then assign the <code>click</code>.</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