完全防止复选框打勾

完全防止复选框打勾

本文介绍了完全防止复选框打勾/检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被要求禁用复选框的勾选".我没有被要求禁用复选框,而是简单地禁用勾选".

I have been asked to disable the "ticking" of a checkbox. I am not being asked to disable the checkbox, but to simply disable the "ticking".

换句话说,用户会认为复选框是可勾选的,但事实并非如此.相反,单击复选框将导致出现一个模式对话框,为用户提供更多选项来打开或关闭复选框所代表的功能.如果对话框中选择的选项导致该功能被打开,则复选框将被勾选.

In other words, a user will think that a checkbox is tickable, but it is not. Instead, clicking on the checkbox will cause a modal dialog to appear, giving the user more options to turn on or off the feature that the checkbox represents. If the options chosen in the dialog cause the feature to be turned on, then the checkbox will be ticked.

现在,真正的问题是,对于一瞬间,您仍然可以看到复选框被选中.

Now, the real problem is that for a split second, you can still see that the checkbox is being ticked.

我尝试过这样的方法:

<input type='checkbox' onclick='return false' onkeydown='return false' />

$('input[type="checkbox"]').click(function(event) {
    event.preventDefault();
    alert('Break');
});

如果你运行这个,警报会出现,表明刻度是可见的(警报只是为了证明它仍然被勾选,在生产中,警报不存在).在某些机器速度较慢的用户和/或渲染器/javascript 速度较慢的浏览器中,用户可以看到非常微弱的闪烁(闪烁有时会持续半秒,这很明显).

If you run this, the alert will appear, showing that the tick is visible (the alert is just there to demonstrate that it still does get ticked, in production, the alert is not there). On some users with slower machines and/or in browsers with slow renderers/javascript, users can see a very faint flicker (the flicker sometimes lasts for half a second, which is noticeable).

我团队中的一名测试人员将此标记为缺陷,我应该修复它.我不知道还有什么办法可以防止复选框中的勾号闪烁!

A tester in my team has flagged this as a defect and I am supposed to fix it. I'm not sure what else I can try to prevent the tick in the checkbox from flickering!

推荐答案

尝试

event.stopPropagation();

http://jsfiddle.net/DrKfE/3/

这篇关于完全防止复选框打勾/检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 06:26