[英]e.PreventDefault submit issue in qtip
我正在尝试让我的表单在qtip工具提示中提交而无需加载页面。 但是,单击提交后,我似乎无法停止加载页面。 它可以在href上正常工作,但不能在表单中的“提交”按钮上工作。
//This One Is BROKEN
$('#EditGallerySubmit').on('submit', function (e) {
e.preventDefault();
});
//This One Is Working Good As Expected
$('.EditGallery').on('click', function (e) {
e.preventDefault();
});
$('.EditGallery').each(function()
{
$(this).qtip({
content: {
text: "Loading...",
ajax: {
url:$(this).attr('href'),
type: "GET",
success: function(data, status) {
this.set('content.text', data);
$('#EditGalleryForm').on('submit', function(e) {
alert($('#EditGalleryForm').attr('action'));
//I added this trying to fix but no luck.
e.PreventDefault();
});
return false;
}
}
},
hide: {
fixed: true,
delay: 100
},
style: 'wiki'
});
$(this).qtip('click', true);
});
表格
<form id="EditGalleryForm" action="Crowork.Backend/Crowork.EditGallery.php?action=DoEditGallery&gallerykey=<?php echo $GalleryData['GalleryID']?>" method="post">
<table border="0" width="100%">
<tr>
<td colspan="2" align="center"><font size="-1"><b>NOTE:</b> Letters & Numbers Only</font></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="GalleryName" size="30" value="<?php echo $GalleryData['GalleryName']?>"></td>
</tr>
<tr>
<td align="right" colspan="2">
<input type="hidden" name="OriginalGalleryName" value="<?php echo $GalleryData['GalleryName']?>">
<input type="hidden" name="GalleryID" value="<?php echo $GalleryData['GalleryID'] ?>">
<input id="EditGallerySubmit" type="submit" name="EditGallery" value="Edit Gallery">
</td>
</tr>
</table>
</form>
我认为您正在通过“提交”按钮附加“提交事件”。 附上表格编号以提交活动
$('#EditGalleryForm').on('submit', function (e) {
e.preventDefault();
});
我认为这可能对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.