Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 没有所有默认类的jQuery UI对话框按钮?_Javascript_Jquery_Jquery Ui - Fatal编程技术网

Javascript 没有所有默认类的jQuery UI对话框按钮?

Javascript 没有所有默认类的jQuery UI对话框按钮?,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我以编程方式创建jQueryUI对话框,如中所示 $( "#dialog" ).dialog({ autoOpen: false, width: 400, buttons: [ { class: "myButton", text: "Ok", click: function() { $( t

我以编程方式创建jQueryUI对话框,如中所示

$( "#dialog" ).dialog({
        autoOpen: false,
        width: 400,
        buttons: [
            {
                class: "myButton",
                text: "Ok",
                click: function() {
                    $( this ).dialog( "close" );
                }
            },
            {
                text: "Cancel",
                click: function() {
                    $( this ).dialog( "close" );
                }
            }
        ]
    });
但是,当创建对话框时,按钮将有一个默认类列表分配给它,标签将被包装在一个范围内

<button type="button" class="myButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false">
     <span class="ui-button-text">Ok</span>
 </button>

我如何才能做到这一点?

有3种简单的方法可以做到这一点:(只需使用以下方法之一)

1只需在代码中将按钮创建为html字符串:

例如:
$(“#someelem”).html(“Ok”)

2下载未压缩的jQueryUI,并更改代码,使输出仅为您传递的类,而不向html添加范围

jQuery用户界面代码中的EX:

var buttonElement = this.buttonElement.removeClass( typeClasses ),
            buttonText = $( "<span></span>", this.document[0] )
                .addClass( "ui-button-text" )
                .html( this.options.label )
                .appendTo( buttonElement.empty() )
                .text(),
            icons = this.options.icons,
            multipleIcons = icons.primary && icons.secondary,
            buttonClasses = [];
var buttonElement=this.buttonElement.removeClass(类型类),
buttonText=$(“”,此.document[0])
.addClass(“ui按钮文本”)
.html(this.options.label)
.appendTo(buttonElement.empty())
.text(),
icons=this.options.icons,
多重图标=icons.primary和icons.secondary,
buttonClasses=[];
只需删除span标记,使buttonText=this.options.label;或者类似的东西

3创建后用JavaScript更改类和按钮html。 例如:
$(.myButton”).attr(“class”,“myButton”).html(“Ok”)


可以使用“创建”函数代替“打开”函数

不要使用jquery ui。做你自己的css。编辑:我的意思是不要使用jquery对话框创建按钮,而是添加自己的按钮。这就是jquery UI的工作方式,它在内部使用所有这些类。如果他们干扰了你的应用程序,你就做错了。好方法。我来看看哪个最有效,谢谢。
var buttonElement = this.buttonElement.removeClass( typeClasses ),
            buttonText = $( "<span></span>", this.document[0] )
                .addClass( "ui-button-text" )
                .html( this.options.label )
                .appendTo( buttonElement.empty() )
                .text(),
            icons = this.options.icons,
            multipleIcons = icons.primary && icons.secondary,
            buttonClasses = [];
$( "#dialog" ).dialog({
  autoOpen: false,
  width: 400,
  open: function(){
    $(this).next().find("button").removeClass("ui-button ui-corner-all ui-widget");
  },
  buttons: [
    {
      class: "myButton",
      text: "Ok",
      click: function() {
        $( this ).dialog( "close" );
      }
    },
    {
      text: "Cancel",
      click: function() {
        $( this ).dialog( "close" );
      }
    }
  ]
});