Matt Jameson
Matt Jameson

Reputation: 217

jQuery mobile close popup

I'm trying to close a popup window with a button in the code below. However, when I call the close function, it doesn't seem to work:

 $('#popupBasic').popup("close");

Here is the html code:

<a href="#popupBasic" id="StopButton" data-rel="popup" data-role="button" data-theme="a" onclick="getLocation2(); Workoutdistance();" data-inline="true" class="">Stop</a>

<div data-role="popup" id="popupBasic">
    <a href="" data-role="button" onclick="database()" data-inline="true" data-theme="a">Submit to DB</a> 
</div>

Any ideas?

Upvotes: 1

Views: 9037

Answers (2)

Haris Setiawan
Haris Setiawan

Reputation: 33

you can add this code, so the x-icon (Close) will appear in top-right of your popup

<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>

below the div

<div data-role="popup" id="popupBasic">
    <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>
    <a href="" data-role="button" onclick="database()" data-inline="true" data-theme="a">Submit to DB</a> 
</div>

Upvotes: 2

Matt Jameson
Matt Jameson

Reputation: 217

Turns out I was referencing the jQuery script twice. It works perfectly now.

Upvotes: 0

Related Questions