jquery滑块在通过ajax加载时不起作用

问题描述:

我正在使用jquery滑块插件创建一些滑块。当我启动dom时直接加载它,但是当我尝试使用它们没有被暗示的ajax innerHTML方法加载滑块到一个div时,这可以正常工作。

I am using the jquery slider plugin to create some sliders. This works fine when I load them directly when the dom is initiated however when I try to load the sliders into a div using the ajax innerHTML method they do not get intiated.

有什么事情可以做到吗?

Does anything know how I can do this?

你必须重新启动/绑定你的事件。

You have to initiate / bind your events again.

例如

//Ajax done and innerHTML is set
$('container').slider(); //Just an example... this will bind events.

您可以更改事件处理程序到 .live 。这可以处理动态内容。

You can change the event handlers to .live . This handles dynamic content.