Last active
August 7, 2019 07:26
-
-
Save grekodev/879f5bcb44eb04caf8c26be58e94132b to your computer and use it in GitHub Desktop.
Revisions
-
grekodev revised this gist
Aug 7, 2019 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,4 +15,9 @@ } }; ko.applyBindings({}); });</script> //use <div class="form-horizontal" data-bind="nextEnter:true"> // your_inputs </div> -
grekodev created this gist
Aug 7, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.0/knockout-min.js"></script> <script> $(document).ready(() => { ko.bindingHandlers.nextEnter = { init: function (element, valueAccessor, allBindingsAccessor) { $(element).on('keydown', 'input, select', function (e) { var self = $(this), form = $(element), focusable, next; if (e.keyCode == 13) { focusable = form.find('input,a,select,button,textarea').filter(':visible'); var nextIndex = focusable.index(this) == focusable.length - 1 ? 0 : focusable.index(this) + 1; next = focusable.eq(nextIndex); next.focus(); return false; } }); } }; ko.applyBindings({}); });</script>