简体   繁体   English

如何将属性添加到Jquery对话框?

[英]How do I add an attribute to a Jquery dialog?

I have a dialog function from jquery that works fine. 我有一个来自jquery的对话功能,工作正常。 I also have a "Processing" function in my javascript that gets triggered when any submit/href link is posted. 我的javascript中还有一个“处理”功能,当发布任何提交/ href链接时会触发该功能。 The close button ("x" in the top right corner) triggers the submit/href function somehow. 关闭按钮(右上角的“x”)以某种方式触发提交/ href功能。 I would like to add an onclick attribute on the close button to call my "NoProcessing" (js function to prevent the href/submit processing.js file from being triggered) when it closes. 我想在关闭按钮上添加一个onclick属性来调用我的“NoProcessing”(js函数以防止href / submit processing.js文件被触发)。 How do I add do that? 我该如何添加呢?

<script>
$(document).ready(function() {
  $("#dialog").dialog(
      autoOpen: false,
      overflow: 'hidden',
      width: ($('#dialog').width() + 130)
  );
});
</script>

There is already a close event 已经有一个紧密的事件

<script>
$(document).ready(function() {
  $("#dialog").dialog(
      autoOpen: false,
      overflow: 'hidden',
        close: function(event, ui) { 
            // do somehting
                            //maybe 
                          event.preventDefault();
                          notProcesseing();

        },
      width: ($('#dialog').width() + 130)
  );
});
</script>

It should be on 'beforeClose'. 它应该在'beforeClose'上。 Close is fired after the dialog is already closed. 对话框已关闭后触发关闭。

$("#dialog").dialog({
    beforeClose: function(event, ui) { 
        event.preventDefault(true); 
    }
});

UPDATE: Then to remove the anchor or href tag, you could: 更新:然后删除锚或href标记,您可以:

$("#dialog").dialog({
    open: function(event, ui) { 
        $('span.ui-icon-closethick').removeAttr('href');
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM