Tom Simon
Posts: 0
Joined: Mon Feb 16, 2015 1:03 pm

Closing a Popup using Javascript

I need to open a popup window when an input field is clicked, but when the button in the popup is pressed I need the popup to close and focus on the same field that was just clicked.

It seems to me the best way to do this is to use a click event that closes the popup and focuses on the input field.

What is the best way to do this?

Thanks.

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

Closing a Popup using Javascript

Hi Tom Simon,

there are two ways to close popup in javascript:

1 . Appery("yourpopupname").popup("close");

  1. $( "#yourpopupname" ).popup( "close" );

    and to focus the textinput try the code below:

    Appery("textinputname").focus();

    then make a condition when the popupclose, the textinput must focus.

Tom Simon
Posts: 0
Joined: Mon Feb 16, 2015 1:03 pm

Closing a Popup using Javascript

I already tried that, but it does not work. As described above I am clicking on an input field. I have an event defined to process the click and fire a popup.

From that popup I have a couple buttons, and one of them has an event to close that popup and focus on the same input field I clicked. The popup closes, but it won't focus on the field.

Ultimately, what I am trying to do is warn the user before he makes changes to the input field. I just need a confirmation (button 1) from the popup before he makes the input field changes.

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

Closing a Popup using Javascript

I already tried your problem, using this code:

if (Appery("mobilepopup_33").popup("close")){
Appery("input").focus();
}

and it works without any problem.

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

Closing a Popup using Javascript

Tom Simon
Posts: 0
Joined: Mon Feb 16, 2015 1:03 pm

Closing a Popup using Javascript

I was so close ... I put the if statement in and it worked.

Thanks so much, She!

Return to “Issues”