简体   繁体   English

如何在jQuery UI对话框窗口中添加额外的对话框小部件关闭按钮

[英]how do I add an extra Dialog Widget close button to a jquery ui Dialog window

the standard code to close the window with the X on the top right is this: 用右上角的X关闭窗口的标准代码是这样的:

<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close"><span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span></button>

I need to add a "Close" button at the bottom of the modal popup window. 我需要在模式弹出窗口的底部添加一个“关闭”按钮。

thanks 谢谢

Initialize the dialog with the buttons option specified: 使用指定的按钮选项初始化对话框:

$( ".selector" ).dialog({ buttons: [ { text: "Close", click: function() { $( this ).dialog( "close" ); } } ] });

Or set the buttons after initialization: 或在初始化后设置按钮:

$( ".selector" ).dialog( "option", "buttons", [ { text: "Close", click: function() { $( this ).dialog( "close" ); } } ] );

If you can visit the jQuery UI Dialog page, which also has other customizations along with the default functionality. 如果您可以访问jQuery UI对话框页面,该页面还具有其他自定义功能以及默认功能。

We also can customize how the display should be. 我们还可以自定义显示方式。 The Dialog in jQuery has .button property for which we can create our own customized buttons. jQuery中的对话框具有.button属性,我们可以为其创建自己的自定义按钮。

Here is the js for buttons 这是按钮的js

buttons: {
     submit: function(){
      //write your code for submission
     },
     close: function(){
         $(this).dialog('close');
     }

This has to be embedded in the dialog method of jQuery. 这必须嵌入到jQuery的dialog方法中。

Here is the fiddle that should answer your question 这是小提琴,应该回答您的问题

FIDDLE 小提琴

Hope it helps. 希望能帮助到你。

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

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