我使用的是当作ajaxForm jQuery插件来提交表单上我的Web应用程序。然而,在应用程序的一部分,我加载一些内容通过jQuery的.load thathas表格就可以了()
I'm using the ajaxForm plugin for jQuery to submit forms on my webapp. However, in one part of the app, I'm loading some content thathas a form on it via jQuery's .load()
问题在于,我不能当作ajaxForm绑定到通过AJAX加载的形式。
The problem lies in that I can't get ajaxForm to bind to the form loaded via ajax.
我已经试过这code无济于事:
I've tried this code to no avail:
$('#viewRecordBtn').live('click', function() { // Handle the event when the 'view record' button is clicked
$("#tab2").load('ajax/viewRecord.php'); // Load the record and the form into tab 2
$('#formAddRecord').ajaxForm(formAddRecordOptions); // Bind the form
});
任何帮助,真是AP preciated !!
Any help is REALLY appreciated!!
编辑:谢谢你们!这完美的作品。
Thanks guys! This works perfectly.
我觉得你应该把约束code到一个回调,因为负载是异步的:
I think you should put binding code into a callback, because the load is asynchronous:
$('#viewRecordBtn').live('click', function() { // Handle the event when the 'view record' button is clicked
$("#tab2").load('ajax/viewRecord.php', function() {
$('#formAddRecord').ajaxForm(formAddRecordOptions); // Bind the form
}); // Load the record and the form into tab 2
});