【发布时间】:2010-09-17 19:51:30
【问题描述】:
当我点击一个 jquery ui 按钮时,它仍然会触发点击事件回调。如何阻止该事件?我必须手动跟踪状态还是 jquery ui 会为我处理这些?
【问题讨论】:
-
你能把你的代码放上来吗?
当我点击一个 jquery ui 按钮时,它仍然会触发点击事件回调。如何阻止该事件?我必须手动跟踪状态还是 jquery ui 会为我处理这些?
【问题讨论】:
试试这个。
$('#button_id').button("disable");
$('#button_id').button("enable");
【讨论】:
$('#button_id').button("disable") 时,不会为 button_id 触发 .click() 处理程序,然后在我调用 $('#button_id').button('enable') 时正确地重新启用
它对我有用:
$("#button_id").attr("disabled", true).addClass("ui-state-disabled");
【讨论】:
根据文档:
// setter
$( "#button_id" ).button( "option", "disabled", true );
【讨论】:
$( "selector" ).button() .click(function () { if (this.checked) $(this).button("option", "icons", {secondary: "ui-icon-circle-check"}) }) .filter(":checked").button({icons: {secondary: "ui-icon-circle-check"}}) .filter(":disabled").button( "option", "disabled", true ); });
如果你这样定义:
$("#mybtn").button();
您必须像这样启用/禁用:
$("#mybtn").button("enable");
// OR
$("#mybtn").button("disable");
【讨论】:
其实是:
$("#btn").button({"disabled":true});
【讨论】: