我们当前绑定到提交按钮的单击事件(我们没有绑定到表单的提交事件是有原因的)。是否保证我们的JS将在表单提交之前运行(因为我们正在向想要提交的隐藏字段输入值),或者我们是否需要阻止表单提交,然后再次调用提交?
$(function() {
$('#button').on('click', function() {
// Do some stuff here - needs to finish before the form submits
return true;
});
});
提前感谢!
我在下面的代码中观察到了一些奇怪的行为:
$.fn.submit_to_remote = function() {
// I use .each instead of the .submit directly so I can save
// the 'submitEnabled' variable separately for each form
jQuery.each($(this), function() {
$(this).submit(function() {
form = $(this);
if (form.data(