我是Jquery的新手。我有一个对话代码。
$(this.choosePadsContainer).dialog({
title: 'Choose pad locations',
autoOpen: false,
modal: true,
buttons: { "OK": function () {
//Extract all checked pad locations.
var checkedPads;
checkedPads = new Array();
$(self.padLocationsForActivity + " input:checked").each(function (index, value) {
checkedPads.push($(value).val());
});
//Set selected pad text.
setSelectedPadText(self.selectedPadsLblIdFormat, $(self.hiddenActivityAreaCode).val(), checkedPads);
$(this).dialog("close");
}
}
});
我想将css类提供给OK按钮。怎么做?
答案 0 :(得分:9)
对buttons
属性使用alternate(array)语法:
$(this.choosePadsContainer).dialog({
title: 'Choose pad locations',
autoOpen: false,
modal: true,
buttons: [
{
text: 'OK',
className: 'myClass',
click: function () {
//Extract all checked pad locations.
var checkedPads;
checkedPads = new Array();
$(self.padLocationsForActivity + " input:checked").each(function (index, value) {
checkedPads.push($(value).val());
});
//Set selected pad text.
setSelectedPadText(self.selectedPadsLblIdFormat, $(self.hiddenActivityAreaCode).val(), checkedPads);
$(this).dialog("close");
}
}
]
});
答案 1 :(得分:2)
根据tvanfosson的回答here,您可以使用开放处理程序:
open: function(event) {
$('.ui-dialog-buttonpane').find('button:contains("OK")').addClass('okButton');
}
E.G。
$(this.choosePadsContainer).dialog({
title: 'Choose pad locations',
autoOpen: false,
modal: true,
open: function(event) {
$('.ui-dialog-buttonpane').find('button:contains("OK")').addClass('okButton');
},
buttons: { "OK": function () {
//Extract all checked pad locations.
var checkedPads;
checkedPads = new Array();
$(self.padLocationsForActivity + " input:checked").each(function (index, value) {
checkedPads.push($(value).val());
});
//Set selected pad text.
setSelectedPadText(self.selectedPadsLblIdFormat, $(self.hiddenActivityAreaCode).val(), checkedPads);
$(this).dialog("close");
}
}
});
答案 2 :(得分:0)
我认为你可以做这样的事情。
$(window).load(function() {
$("span[class=ui-button-text]:contains('OK')").each(function() {
$(this).addClass("myClass");
});
});
答案 3 :(得分:0)
AFAIK没有直接支持,但这应该有用:
$(".ui-dialog-buttonset .ui-button", this.choosePadsContainer).addClass("foo");