Created
December 5, 2019 04:43
-
-
Save chabibnr/4abd76f39f050fdc943721b553127c85 to your computer and use it in GitHub Desktop.
Yii - enter as tab
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
$JS = <<<JS | |
$('body').on('keydown', 'input, select', function(e) { | |
if (e.key === "Enter") { | |
var self = $(this), form = self.parents('form:eq(0)'), focusable, next; | |
focusable = form.find('input,a,select,button,textarea').filter(':visible'); | |
next = focusable.eq(focusable.index(this)+1); | |
if (next.length) { | |
next.focus(); | |
} else { | |
form.submit(); | |
} | |
return false; | |
} | |
}); | |
JS; | |
$this->registerJs($JS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment