2

i want to focus a disabled button. i have a form with some inputs, ng-repeats and a confirm button. if i tab throw these elements all works fine. but if my confirm button is disabled it dont get the focus. any idears how to give the focus in the right order if its disabled? this is the button:

<button type="submit" 
        class="btn btn-adesso" 
        ng-disabled="!newRepoForm.$valid||isSend">
    Absenden 
</button>

the validation (via REST) of the last input field is triggered when the focus is lost. so if you fill in the last field and tab on, the confirm button is disabled cause form "waits" for the rest validation. so the confirm button is disabled for the moment of REST validation and dont get the focus but it should get the focus. and then the button will be enabled when validation finished

Hans
  • 119
  • 1
  • 12
  • Could you give a fiddle showing this behaviour ? – Okazari May 13 '15 at 08:04
  • http://plnkr.co/edit/7uOMttgKuW42Qw5H38Vp?p=preview if i tab throw the inputs and the button, i dont get the focus of the button cause its disabled. i want also get the focus when its disabled. any ideas? – Hans May 13 '15 at 08:19
  • It looks like disabled element can't get focus. 2nd question then, why do you want to do that ? – Okazari May 13 '15 at 08:26
  • the validation (via REST) of the last input field is triggered when the focus is lost. so if you fill in the last field and tab on, the confirm button is disabled cause form "waits" for the rest validation. so the confirm button is disabled for the moment of REST validation and dont get the focus – Hans May 13 '15 at 09:55
  • if there is no way to focus a disabled button i will workaround and focus the button if the form become valid – Hans May 13 '15 at 09:56
  • Ok i get it i actually didn't know that you can't focus a disabled html element. Add your explanation to your question, i'll upvote it. – Okazari May 13 '15 at 09:58

1 Answers1

0

Hans, see this post : AngularJS and Tab Order (Disabled Buttons) (it seems that certain browsers pick up the focus and others do not. There is also a 'hack' (workaround) given, which might suit your immediate needs)

GL!

Community
  • 1
  • 1
Shehryar Abbasi
  • 378
  • 2
  • 8