Skip to content

Instantly share code, notes, and snippets.

@remvee
Created December 4, 2009 14:25
Show Gist options
  • Save remvee/249041 to your computer and use it in GitHub Desktop.
Save remvee/249041 to your computer and use it in GitHub Desktop.
JS onchange hack for input[type=hidden]
// 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