如何禁用按钮on the jQuery UI dialog。我似乎在上面链接的任何文档中都找不到这一点。
我有两个模式确认按钮(“确认”和“取消”)。在某些情况下,我想禁用“确认”按钮。
发布于 2010-11-26 02:13:32
看起来任何人,甚至在this linked question,都提出了这个解决方案,类似于Nick Craver给出的答案的第一部分:
$("#dialog").dialog({
width: 480,
height: "auto",
buttons: [
{
id: "button-cancel",
text: "Cancel",
click: function() {
$(this).dialog("close");
}
},
{
id: "button-ok",
text: "Ok",
click: function() {
$(this).dialog("close");
}
}
]
});
然后,在其他地方,您应该能够使用jquery UI按钮的API:
$("#button-ok").button("disable");
发布于 2011-04-23 23:54:30
以下是按钮单击功能中的工作方式:
$(function() {
$("#dialog").dialog({
height: 'auto', width: 700, modal: true,
buttons: {
'Add to request list': function(evt) {
// get DOM element for button
var buttonDomElement = evt.target;
// Disable the button
$(buttonDomElement).attr('disabled', true);
$('form').submit();
},
'Cancel': function() {
$(this).dialog('close');
}
}
});
}
发布于 2010-09-05 22:42:40
按钮由类ui-button
标识。要禁用按钮,请执行以下操作:
$("#myButton").addClass("ui-state-disabled").attr("disabled", true);
除非您正在动态创建对话框(这是可能的),否则您将知道按钮的位置。因此,要禁用第一个按钮:
$("#myButton:eq(0)").addClass("ui-state-disabled").attr("disabled", true);
ui-state-disabled
类提供了一个漂亮的暗淡样式的按钮。
https://stackoverflow.com/questions/3646408
复制相似问题