[英]ExtJS: disable checkbox toggle on label click
I am designing a checkbox for a for and I absolutely cannot have the checkbox to toggle when the user clicks on its label, as this label contains a link to open a small infobox where the user gets to know what he or she is accepting by selecting the checkbox. 我正在为for设计一个复选框,当用户单击其标签时,我绝对不能切换该复选框,因为此标签包含一个打开小信息框的链接,用户可以通过选择该框来了解他或她接受的内容复选框。
How can I disable checkbox toggle when clicking on its label? 单击标签时如何禁用复选框切换?
The code looks simply like this (this element is inside a FormPanel items list:) 代码看起来像这样(此元素在FormPanel项目列表中:)
{ xtype:'checkbox', id: 'privacyCheck', fieldLabel: 'I have read, understood and accepted the privacy policy of ABCDE' } {xtype:'checkbox',id:'privacyCheck',fieldLabel:'我已阅读,理解并接受ABCDE的隐私政策'}
Instead of using the boxLabel property or field label on the checkbox, create a separate label object next to the checkbox. 与其在复选框上使用boxLabel属性或字段标签,不如在复选框旁边创建一个单独的标签对象。 This should make it easier to manipulate your handler for the label.
这应该使操作标签的处理程序更加容易。 Otherwise, you will need to dig through the appropriate DOM element for the boxLabel (not pretty) to get at it.
否则,您将需要为boxLabel(不是很漂亮)挖掘适当的DOM元素。
I know, this topic is rather old, but I found it, searching for a solution to the exact same problem. 我知道,这个主题比较旧,但是我找到了,正在寻找完全相同的问题的解决方案。 So I'd like to share.
所以我想分享。
I needed to modify the browsers behaviour to mimick the behaviour of a legacy site, while making said site "accessible". 我需要修改浏览器的行为,以模仿旧站点的行为,同时使该站点“可访问”。 (The for-attribute of the label tag is needed and a label without a for-attribute can not be used.)
(需要label标签的for-attribute,并且不能使用没有for-attribute的标签。)
I don't know about ExtJS, but since the legacy site uses jQuery in the frontend, I solved the problem this way: 我不了解ExtJS,但是由于旧站点在前端使用jQuery,因此我通过以下方式解决了问题:
//[...]
$(document).ready(function () {
$('.donotToogleCheckbox').click(function (event) {
event.preventDefault();
// do other stuff like displaying a dialog or something
})
});
//[...]
<label class='donotToogleCheckbox' for='myCheckbox'>DaLabel</label>
<input id='myCheckbox' name='myCheckbox' type="checkbox">
//[...]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.