[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-13 Thread Sander Elias
Aside from the not working with ngRepeat, does the original directive do what it's supposed to do? -- You received this message because you are subscribed to the Google Groups "Angular" group. To unsubscribe from this group and stop receiving emails from it, send an email to

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-13 Thread Esa Yletyinen
Hi, Here's my situation: // clicking "next" (e.g. tab, enter, down arrow) moves to the last text input (tabIndex 2) // clicking "next" (e.g. tab, enter, down arrow) moves to the last text input (tabIndex 2) // clicking "next" (e.g. tab, enter, down arrow) moves to the last text input

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-13 Thread Sander Elias
Hi Esa, This is where you need to utilize the tabindex attribute (I can adapt my code for that, but it's a bit too much work do do that for just a quick sample...) You can set the tabindex using your directive. As I don't know what your specific instance is, I can't help you on this. Of

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-13 Thread Esa Yletyinen
I understand that, but I want it to specifically IGNORE the next element that can receive focus in a specific instance, and set focus on the next element with a specific value of a given attribute, that element being generated by ng-repeat. As described in the other topic I created, I don't

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-13 Thread Sander Elias
Hi Esa, It doesn't set the focus on the next random element. It sets the focus on the next element THAT CAN RECEIVE focus. It ignores tab-order, but that can be fixed in the code. If that's not what you need, the code is also easy to adapt to select whatever criteria you might have. Just adapt

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-12 Thread Esa Yletyinen
Thank you very much. My mistake in my previous question was attempting to access the element by "el" rather than "el[0]". I managed to get my version to work. However, in my case I really do need to access inputs by attribute value, rather than relying on simply the next element in document. I

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-12 Thread Sander Elias
Pushed an update with an ES5 traversal. Here is the result from babel: 'use strict'; function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } //es5 helper

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-12 Thread Sander Elias
What browsers do you need to support? Changes are that generators are in there already, so you don't need the regenarator runtime. -- You received this message because you are subscribed to the Google Groups "Angular" group. To unsubscribe from this group and stop receiving emails from it,

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-12 Thread Esa Yletyinen
> > Thank you. > > However, I need this in ES5, preferably in the following form: > > app.directive('focusNext', function() { > return { > restrict: 'A', > link: function(scope, el) { > el.bind('keydown', function(event) { > if (event.keyCode ===

[AngularJS] Re: set focus on a specific dynamically input on keydown

2017-01-11 Thread Sander Elias
Hi Esa, Usually, messing with the focus order in this way is frowned upon. It's better to let the browser handle that. There is a whole slew of usability issues concerned with this. Have a look at the solution I created here for you. It's