Created
November 13, 2012 21:21
-
-
Save ayumi/4068476 to your computer and use it in GitHub Desktop.
[cs] Extend JQuery to bind changes in content, and skip general keypresses.
This file contains hidden or 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
# Bind changes in content. Skip general keypresses. | |
$.fn.onValChange = (callback) -> | |
# IE < 9 | |
usePropertyChange = true | |
this.on("propertychange.onValChange", (e) => | |
callback.call(this) if (e.originalEvent.propertyName == "value") | |
return | |
) | |
# HTML5 | |
this.on("input.onValChange", (e) => | |
# This event fires before the above, unbinding it if we're not in IE. | |
if usePropertyChange | |
this.off("propertychange.onValChange") | |
callback.call(this) | |
return | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment