Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to execute another action after generated by ajax with jQuery?
    text
    copied!<p>I have <a href="http://pastie.org/798788" rel="nofollow noreferrer">this ajax function</a> with jquery. (<a href="http://pastie.org/798788" rel="nofollow noreferrer">http://pastie.org/798788</a>)</p> <p>The outputs is the following.</p> <pre><code>&lt;div class="content"&gt; &lt;h1&gt;Latest Messages or Task To Do&lt;/h1&gt; &lt;ul style="display: block;" id="message_ul"&gt; &lt;li class="86"&gt; &lt;div class="listbox"&gt;&lt;span class="user"&gt; &lt;strong&gt;Administrator&lt;/strong&gt;&lt;/span&gt; &lt;span class="date"&gt;2010-01-28 08:57:43&lt;/span&gt; &lt;a href="http://127.0.0.1/ci_backendpro2/index.php/messages/admin/changestatus/86" class="todo"&gt;to do&lt;/a&gt; &lt;span class="msg"&gt;Change links in message, to do, completed and delete to anchor &lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="85"&gt; &lt;div class="listbox"&gt;&lt;span class="user"&gt; &lt;strong&gt;Administrator&lt;/strong&gt;&lt;/span&gt; &lt;span class="date"&gt;2010-01-28 08:51:15&lt;/span&gt; &lt;a href="http://127.0.0.1/ci_backendpro2/index.php/messages/admin/changestatus/85" class="todo"&gt;to do&lt;/a&gt; &lt;span class="msg"&gt; meta tag keywords and description should show from page input/database &lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="84"&gt; ... ... </code></pre> <p>Now I am trying to add another ajax with class="todo". However when I tried this for testing. It does not alert. It executes the php function.</p> <pre><code>$(".todo").click(function(){ event.preventDefault(); alert("hei"); }); </code></pre> <p>I am not sure why. Is it because it is created by ajax? </p> <p>Is it something to do with binding?</p> <p>How can I make it work?</p> <p>I thank your help in advance.</p> <p>Additional info. By the way I am using codeigniter. Other <a href="http://pastie.org/798802" rel="nofollow noreferrer">php functions are here</a>. <a href="http://pastie.org/798802" rel="nofollow noreferrer">(http://pastie.org/798802)</a></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