防止在表单提交时关闭模式
有没有办法在提交表单时防止模式关闭?
我正在开发一个通过简单模式呈现的 div 向用户呈现的表单。
// modal call $('#edit_container', document).modal( {onOpen: function (dialog) { dialog.overlay.fadeIn('fast', function () { dialog.data.hide(); dialog.container.fadeIn('fast', function () { dialog.data.slideDown('fast'); }); }); } , onClose: function(dialog) { location.reload(true); $.modal.close(); } }); // simplemodal settings $.modal.defaults = { appendTo: 'body', focus: false, opacity: 70, overlayId: 'simplemodal-overlay', overlayCss: {}, containerId: 'simplemodal-container', containerCss: {}, dataId: 'simplemodal-data', dataCss: {}, minHeight: null, minWidth: null, maxHeight: null, maxWidth: null, autoResize: true, autoPosition: true, zIndex: 1000, close: true, closeHTML: '', closeClass: 'simplemodal-close', escClose: false, overlayClose: false, position: null, persist: true, modal: true, onOpen: null, onShow: null, onClose: null };
我有一个 jquery 函数可以更新模态 div 中的表格:
// on submit function $('form#family-form').submit(function() { var condition = $('#edit-health',this).val(); $('>li> + condition + >/li>', document).appendTo('#health_edit_table td ul'); });
有什么想法吗?
谢谢, 乔纳森
Is there a way to prevent the modal from closing when a form is submitted?
I'm working on a form presented to users via a simplemodal presented div.
// modal call $('#edit_container', document).modal( {onOpen: function (dialog) { dialog.overlay.fadeIn('fast', function () { dialog.data.hide(); dialog.container.fadeIn('fast', function () { dialog.data.slideDown('fast'); }); }); } , onClose: function(dialog) { location.reload(true); $.modal.close(); } }); // simplemodal settings $.modal.defaults = { appendTo: 'body', focus: false, opacity: 70, overlayId: 'simplemodal-overlay', overlayCss: {}, containerId: 'simplemodal-container', containerCss: {}, dataId: 'simplemodal-data', dataCss: {}, minHeight: null, minWidth: null, maxHeight: null, maxWidth: null, autoResize: true, autoPosition: true, zIndex: 1000, close: true, closeHTML: '', closeClass: 'simplemodal-close', escClose: false, overlayClose: false, position: null, persist: true, modal: true, onOpen: null, onShow: null, onClose: null };
I have a jquery function that updates a table within the modal div:
// on submit function $('form#family-form').submit(function() { var condition = $('#edit-health',this).val(); $('>li> + condition + >/li>', document).appendTo('#health_edit_table td ul'); });
Any thoughts?
Thanks,
Jonathan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实想提交表单,请使用ajax。如果没有,则从您的提交函数返回 false。
If you actually want to submit the form then use ajax. If not then return false from your submit function.
哎呀!我意识到这需要通过 AJAX 或 AHAH (drupal) 调用来完成。除非,任何人有更好的主意。
Woops! I realized that this would need to be done via an AJAX or AHAH (drupal) call. Unless, anyone has a better idea.