Ionic popup autofocus on button


#1

hey there,

i am struggeling with the possibility of having an autofocus on the button in an alert/confirm popup! once the popup is open it should close by pressing a special key (enter f.e.). anyone needed something as well or has an idea of how to achieve that?

very much appreciated,

thx michael


#2

I did something similar and takes $ ionicPopup

$ionicPopup.show({
 title: '',
 subTitle: '',
 content: '',
 buttons: [
   { text: 'Cancel' },
   {
     text: 'Deleted',
     type: 'button-positive',
     onTap: function(e) {
         
          };
     }
   },
 ]
})

#3

hey.

thanks for your reply. this is just a callback if i click the button.

what i need is if the alert popup opens, the button should be automatically focused! so if i press for example “enter” the popup should close. anyone knows how to do that?

many thanks


#4

You have some example image? I can not understand what you want to achieve.


#5

hey!

sorry for the late reply. attached you can see a screenshot. what i mean: if a popup opens… i cannot close it by pressing a defined button (in my case enter key=13). if i press enter i submit still on the form behind the popup. so there is no autofocus option on the opened popup! does this make sense?

and i am searching for an option to autofocus a button in a popup window! i can change that behavior by editing the ionic-bundle file but this is not what i want to do


#6

Have you ever solved this? I was hoping that ionic popup would automatically handle this.


#7

no not really. the only you can do is to change it directly in the ionic code for modals!