Created
December 4, 2009 14:25
-
-
Save remvee/249041 to your computer and use it in GitHub Desktop.
JS onchange hack for input[type=hidden]
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
// make sure you call field.fire('hidden:change') when a hidden field changes | |
document.observe('dom:loaded', function() { | |
$$('input[type=hidden]').each(function(e) { | |
var onchange = e.getAttribute('onchange') | |
if (onchange) { | |
if (typeof(onchange) != 'function') { | |
eval("onchange = (function(event){(function(){" + onchange + "}).bind(Event.element(event))()});"); | |
} | |
e.observe('hidden:change', onchange); | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment