Note that there are some explanatory texts on larger screens.

plurals
  1. PO.live not working after ajax $.post
    primarykey
    data
    text
    <p>I am trying to use .live to ensure that my elements respond to click events even after an ajax call (in my case i use $.post) so for example <strong>after my ajax call</strong> i do this:</p> <pre><code>$('.link').live({ click: function() { alert('testing'); } }); </code></pre> <p>it doesn't working. Only if i switch it to using a normal click event like this:</p> <pre><code>$('.link').click(function() { alert('testing); } </code></pre> <p>it works. But the thing is the <strong>$link</strong> only appears to the user only after each ajax call and is the one actually making the ajax call. So if i use a normal click event, it will only work once after the first ajax call (i bind the event after the first ajax call) which shows the $link for the first time. </p> <p>After the $link is shown for the first time, and is clicked by the user for the first time, it will show a list of items including the $link again at the bottom. However, this time it doesn't work anymore because i am still only binding the click event without using .live.</p> <p>How do i make it so that .live works, which will enable the link to work everytime after N number of times of clicks?</p> <p><strong>Edited:</strong> Change $list to using a selector. Sorry about the unclear information before. I am in fact using a selector for using .live . I am actually trying to provide a 'View more' functionality. So after a user enters something in a textbox, the search results appear (via ajax) and the 'View more' link appears at the bottom. When the user clicks it, more relevant search results will be appended to the list and another 'View more' link will be at the bottom of the list again. However, this time it doesn't work anymore because i can't get the .live to work with it.</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.
 

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