Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT:</strong></p> <p>I've realized the <code>live()</code> function is deprecated and about to be removed on version 1.9, so for everybody's sake I have edited my answer. you should be using the <code>on()</code> function instead. thanks!</p> <hr> <p>ill try to explain this as best as i could.</p> <p>as quoted from my comment..</p> <p>"shouldn't you just use <code>live()</code> instead of <code>click()</code>? see the <a href="http://api.jquery.com/live/" rel="nofollow">API description</a>.. "<strong>Attach an event handler for all elements which match the current selector, now and in the future.</strong>" </p> <p>now, the question is.. what is the difference?</p> <p>using <code>click()</code> would add the event handler to all the targets of the selector you specified in jQuery, it explains the 'NOW' on the API desctipion of <code>live()</code> earlier..</p> <p>ex: <code>$("a[id ^= 'toggle']")</code> would apply only to all the DOM objects when that function was called. </p> <p>so all the new objects inserted into the DOM wouldn't have that 'event handler'</p> <p>but unlike <code>live()</code>, all the objects that would match the original selector would still be bound by the event you added, explaining the 'now and in the future' clause of the description. </p> <p>in other words, it is like calling the same bind function, (in this case <code>click()</code>) every time a new object is inserted into the DOM that matches the original selectors..</p> <p>so instead of the original</p> <pre><code>$("a[id^='toggle']").click(function(event){ </code></pre> <p>you would be using </p> <pre><code>//$("a[id^='toggle']).live('click',function(event){ //EDIT: this is deprecated. use on() instead, see below: $(document.body).on('click', 'a[id^="toggle"]', function() { </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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