Created
April 17, 2011 15:15
-
-
Save kaleb/924110 to your computer and use it in GitHub Desktop.
Detect and fix leaky labels for disabled inputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lbl = document.createElement('label'), | |
chk = document.createElement('input'), | |
proto, lblOnClick; | |
chk.type = 'checkbox'; | |
chk.disabled = true; | |
lbl.appendElement(chk); | |
lbl.click(); | |
if (chk.checked) { | |
// Labels need to be fixed | |
proto = Object.getPrototypeOf(lbl); | |
lblOnclick = function(){ | |
if(this.for.disabled) { | |
// prevent click from happening | |
} | |
} | |
proto.setEventHandler('click', lblOnClick); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment