开发者

Jquery Ajax calls fail after first call success?

开发者 https://www.devze.com 2023-01-27 04:04 出处:网络
I\'m build jquery to build a custom email system (left pane list of messages - right pane the selected or current message) ....

I'm build jquery to build a custom email system (left pane list of messages - right pane the selected or current message) ....

After an Ajax call is made (for example - the message is deleted and the left pane is reloaded using .load to update the list), calls from there fails from there (its as if the reloaded content doesnt see the ajax on the page anymore... and nothing happens)

Below is an example of the jquery that deletes the mail. The deleteMail script also echos the updated list..

$('#leftmail').html(loading).load('/pages/mail/async/deleteMail.p开发者_开发技巧hp',{'id' : id });

Does anyone have any ideas why this would happen? It is a .load things specifically?

Please help! Thanks!

F


Binding events to elements only happens once. When you load the pane via AJAX, those events are lost and not recreated on the newly fetched elements.

The jQuery live() function is designed for this. Instead of $('element').click(function() {}), you'd do $('element').live('click', function() {}) to have those click events work on content loaded after the initial domready event.

0

精彩评论

暂无评论...
验证码 换一张
取 消