Last active
August 9, 2018 14:35
-
-
Save alphamarket/450e860d5819d7a7430a9b6a1b6af889 to your computer and use it in GitHub Desktop.
jQuery.focus() and move cursor at the end of input
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
# jQuery extensions | |
(($) -> | |
_super = { } | |
# | |
# [..] some other extensions | |
# | |
_super.focus = $.fn.focus | |
$.fn.focus = -> | |
# call out the original jQuery focus | |
_super.focus.apply(this, arguments) | |
# set cursor at the end of val | |
v = this.val() | |
this.val('') | |
this.val(v) | |
this | |
return | |
) jQuery | |
# javaScript compilation: | |
# | |
# (function($) { | |
# var _super = {}; | |
# _super.focus = $.fn.focus; | |
# $.fn.focus = function() { | |
# var v; | |
# _super.focus.apply(this, arguments); | |
# v = this.val(); | |
# this.val(''); | |
# this.val(v); | |
# return this; | |
# }; | |
# })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment