The world is not always as we want it to be :). So from now and then you have to place a nice hack here and there. Years ago I’ve already written about a similar issue with input fields.
Doing something like the following..
<input type="checkbox" onclick="return false">
..won’t work. Existing jQuery listeners still fire. What you have to do instead is:
- temporarily store all existing handlers registered on the element
- remove all of them once you have them safely stored somewhere
- register a click and keydown handler which catches the events and prevents them from being propagating upwards
- add some CSS style s.t. the element looks like being disabled
- remove your click/keydown handler which prevents any interaction with the element
- restore all events on the element which you saved before
- remove the “disabled” style
The full code is in this jsFiddle. Enjoy :)