Skip to content

Instantly share code, notes, and snippets.

@MrSwed
Created July 3, 2015 12:07
Show Gist options
  • Select an option

  • Save MrSwed/c56dea524b5185520b78 to your computer and use it in GitHub Desktop.

Select an option

Save MrSwed/c56dea524b5185520b78 to your computer and use it in GitHub Desktop.
Trigger change on changed prop or attr
// it getted from https://forum.jquery.com/topic/should-chk-prop-checked-true-trigger-change-event
$.attrHooks.checked = {
set: function(elem, value, name) {
var ret = (elem[ name ] = value);
$(elem).trigger("change");
return ret;
}
};
$.propHooks.checked = {
set: function(elem, value, name) {
var ret = (elem[ name ] = value);
$(elem).trigger("change");
return ret;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment