我需要将jQuery validate插件绑定到我动态生成的表单.据我所知.live(),这是在jQuery中执行此操作的唯一方法.它似乎不起作用,至少我正在尝试的方式.我认为这是可行的,它只是eebkac!
这很好用:
$("form#form_CreateUser").validate({
submitHandler: function(form) {
// do other stuff for a valid form
UserSubmit();
}
});
Run Code Online (Sandbox Code Playgroud)
这会生成语法错误:
$("form#form_CreateUser").live('validate', function() {
submitHandler: function(form) {
// do other stuff for a valid form
UserSubmit();
}
});
Run Code Online (Sandbox Code Playgroud) 问候大师,这有点难以解释,但我会试一试.
我有一个关于JQuery中的.live()函数的快速问题.我将在这里简化示例.我有一个页面"index.php",它有一个容器"#display_files_container",其中填充了由不同页面"process.php"动态生成的锚链接.<div>当根据该链接的属性选择这些链接时,链接将加载到链接中.见例子:
的index.php
<html>
<head><title>index.php</title>
<!-- this function below loads process.php and passes it the dirid variable via post. I then use this post variable inside of process.php to pull other links from the database -->
<script language="text/javascript">
$('.directory').live("click", function() {
$('#display_files_container').load('plugins/project_files/process.php', {dirid: $(this).attr('dirid')});
});
</script>
</head>
<?php
/*This code initial populates the link array so we have the first links populated before the users clicks for the first time*/
some code to fetch the $current_directory_list array from …Run Code Online (Sandbox Code Playgroud)