防止在表单提交时关闭模式

发布于 2024-10-10 01:04:13 字数 1611 浏览 0 评论 0原文

有没有办法在提交表单时防止模式关闭?

我正在开发一个通过简单模式呈现的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘落散花 2024-10-17 01:04:13

如果您确实想提交表单,请使用ajax。如果没有,则从您的提交函数返回 false。

// on submit function
$('form#family-form').submit(function() {
  var frm = this;
  $.ajax({ 
    url:frm.attr('action'),  
    data:$(frm).serialize(),  
    success:function(data){
      var condition = $('#edit-health',frm).val();
      $('>li> + condition + >/li>', document).appendTo('#health_edit_table td ul');
    }  
  });
  return false;
}); 

If you actually want to submit the form then use ajax. If not then return false from your submit function.

// on submit function
$('form#family-form').submit(function() {
  var frm = this;
  $.ajax({ 
    url:frm.attr('action'),  
    data:$(frm).serialize(),  
    success:function(data){
      var condition = $('#edit-health',frm).val();
      $('>li> + condition + >/li>', document).appendTo('#health_edit_table td ul');
    }  
  });
  return false;
}); 
拥抱没勇气 2024-10-17 01:04:13

哎呀!我意识到这需要通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文