Created
June 1, 2011 14:03
-
-
Save phiggins42/1002345 to your computer and use it in GitHub Desktop.
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
dojo.onEnterPress = function(ref, context, method){ | |
// summary: Shorthand utility function for hooking up enter-key handling to a text input. | |
var ENTER = dojo.keys.ENTER, callback = method ? dojo.hitch(context, method) : context, ev = "keypress"; | |
if(typeof ref == "string"){ | |
ref = dojo.byId(ref); | |
}else if(ref && ref.declaredClass){ | |
ev = "onKeyPress"; | |
} | |
return dojo.connect(ref, ev, function(e){ | |
e && e.charOrCode && e.charOrCode == ENTER && callback(); | |
}); | |
}; | |
// example, call this._runSearch() when they hit enter in a textbox or on the search button: | |
dojo.onEnterPress(widget, this, "_runSearch"); | |
dojo.connect(button, "onClick", this, "_runSearch"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment