让JavaScript在重新加载的AJAX框中运行 [英] Get JavaScript working in a reloaded AJAX box

查看:57
本文介绍了让JavaScript在重新加载的AJAX框中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将AJAX用于页面的一部分(例如评论框)时,在重新加载的框中没有JavaScript起作用。例如例如 cutetime 之类的。因此,我想我必须重新加载 cutetime 命令(在每次重新加载注释框中)

When I use AJAX for part of my page, such as a commentbox, in the reloaded box no JavaScript works. e.g. like cutetime or whatever. So I guess I have to reload the cutetime command (in every reload of the commentbox)

它可以工作,但是我想我有两次 cutetime 命令。如果我有一个确认框或其他任何内容,则会两次出现确认框或add命令。

It works, but I think I have the cutetime command twice. If I have a confirm box or anything other, I get the confirm box or the add command twice.

我将尝试用一个句子来描述它:

我需要一种使JavaScript在重新加载的AJAX-Box中工作的方法。

I'll try to describe it in one sentence:
I need a way to get JavaScript working in a reloaded AJAX-Box.

PS:我认为有一个非常一种简单的方法,因为每个人都使用它:)

P.S.: I think there is a very easy way because everybody uses it :)

推荐答案

如果替换元素,则所有附加到它的内容都会丢失。

If you replace an element anything attached to it is lost.

使用jQuery时,可以通过使用实时事件来避免此问题。但是,这不适用于您不附加事件的插件。在这种情况下,您需要在替换元素时再次调用任何启用元素的函数。

When using jQuery, you can avoid this issue by using live events. However, this doesn't work for plugins where you don't attach events. In that case you need to call whatever function enables something on your element again when replacing it.

这篇关于让JavaScript在重新加载的AJAX框中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆