开发者

Ajax replaces a bunch of HTML, how to update the associated jQuery actions like Drag And Drop?

So I've finally figured out a system for refreshing portions of the screen using Ajax, Taconite, and jQuery within Dja开发者_运维技巧ngo, sortof like Ruby on Rails partials.

I was pleased, but unfortunately, the code associated with clicking and drag and dropping is not executing.

I'm replacing the html inside divs.

How can I keep my code modular (separate pieces of content in refreshable divs), yet make sure my jQuery draggables, droppables, clickables, hoverables, etc get reactivated?

Thanks!

Update

I setup a $(document).ready(callasetupfunction) [as recommended below] and it seems to be getting called after each AJAX call. Is that the expected behavior for .ready?

I've also noticed that i can bind multiple functions to the $(document).ready(). So I can do that (in other words it's a lot better than setting the onload huh?)


Without seeing your code, the only advice I can think of is to pull the portions of your code that call .draggable, etc into a function (probably one that takes a selector), and add that function as a callback after your ajax call completes.

If that doesn't make sense, or is not doable for some reason, and you can put up some working example code that demonstrates the problem, I or someone else can help you find a solution.

Edit: It looks like you might need to stick the call to the above javascript function in a script tag in your response, if you're set on using taconite.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜