0
我正在使用jquery galleryview插件,并且添加了在点击链接(显示表单)时单击暂停幻灯片并在关闭按钮单击时重新启动的功能。jQuery函数没有运行验证表单提交
这工作正常(见下文),但我也想在提交表单时启动幻灯片。我可以通过将提交按钮添加到重新开始幻灯片显示的元素列表来完成此操作,但如果表单未通过验证,我不希望幻灯片重新开始。
这里是我的图库视图代码(浓缩):
(function($){
$.fn.galleryView = function(options) {
// Some code
return this.each(function() {
// Some more code
$("#closeEnquiry").click(function(){
restartGallery();
});
function restartGallery(e) {
// Code to restart gallery
}
}
}
}
,这里是我的表单提交/验证码(restartGallery功能不运行):
$(document).ready(function(){
$("#enquiryForm").validate({
debug: false,
rules: {
YourName: {
required: true,
},
YourEmail: {
required: true,
email: true,
},
},
messages: {
YourName: "Please let us know who you are.",
YourEmail: "A valid email will help us get in touch with you."
},
submitHandler: function(form) {
$.post('projectform.php', $("#enquiryForm").serialize(), function(data) {
closePopup();
$('#enquiryFormContainer').prepend(data);
restartGallery(); // This does not run...
});
}
});
});
任何想法如何,我可以运行restartGallery函数来自validate函数?
在调用'$ .post()'之前,你不能在提交处理程序中调用“restartGallery()”吗? – Pointy 2012-03-02 15:59:08
也许,你应该停止标准表单提交? – kirilloid 2012-03-02 15:59:14
@kirilloid你会建议作为替代方案吗? – Tom 2012-03-02 16:20:59