Page 1 of 1

Closing a Popup using Javascript

Posted: Tue Feb 17, 2015 11:07 pm
by Tom Simon

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.


Closing a Popup using Javascript

Posted: Wed Feb 18, 2015 5:27 am
by She

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.


Closing a Popup using Javascript

Posted: Wed Feb 18, 2015 5:49 am
by Tom Simon

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.


Closing a Popup using Javascript

Posted: Wed Feb 18, 2015 5:54 am
by She

I already tried your problem, using this code:

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

and it works without any problem.


Closing a Popup using Javascript

Posted: Wed Feb 18, 2015 5:58 am
by She

Closing a Popup using Javascript

Posted: Wed Feb 18, 2015 6:36 am
by Tom Simon

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

Thanks so much, She!