fancybox里面的jquery没有工作

Mad*_*han 2 jquery fancybox

我在fancybox中面临着jquery的问题.基本上我有一个通过ajax呈现的表单,它已被加载到fancybox中.但问题是,jquery不能在fancybox加载的表单上工作:(但是当我转到实际的表单页面时它工作正常.

我在这里发现了类似的问题 http://groups.google.com/group/fancybox/browse_thread/thread/fe6f9cad7b42df79,他说使用绝对引用...我甚至试过了,但没有运气.

你们中的任何人都遇到过类似的问题吗?

这是我的jquery代码


$(document).ready(function() {
  $("input#user_username").click(function(e){
    alert("asaadasd");
  }); // this works fine when called through the form loaded in the page, but doesn't when the form is loaded within fancybox

  $("a#login-link, a#login-link2, a#signup-link, a#signup-link2").fancybox({
    'scrolling'   : 'no',
    'titleShow'   : false
  });

});
Run Code Online (Sandbox Code Playgroud)

任何帮助?

Sim*_*olt 5

如果您的表单是通过ajax加载的,则click事件将不会绑定到它,document.ready因为当时它不在文档中.请live()改用.这会将事件绑定到文档中的当前元素和将来元素.

$("input#user_username").live("click", function(e) {
    alert("asaadasd");
});
Run Code Online (Sandbox Code Playgroud)