JavaScript/JQuery: Open/Close Popup

I was having this problem the other where I was using JQuery Mobile popup but I couldn’t close/open it dynamically using JavaScript. Below is the syntax solution to this problem.

This was my popup html tag

<div data-role="popup" id="popupLocation" data-theme="a" style="padding: .5em .5em .5em .5em; min-width:20em;">
   <div id="div-location-back-btn">
      <button data-icon="carat-l" onclick="RaiseEvent('TRAVERSE-UP-LOCATION')" data-inline="true">Back</button>
   <ul id="location-tree" data-role="listview" data-filter="true" data-filter-placeholder="Search location" data-inset="true" style="min-width:210px;"></ul>

JavaScript function to open popup.

function OpenPopup(popupId) {
   $('#' + popupId).popup('open');

JavaScript: Function to close popup.

function ClosePopup(popupId) {
   $('#' + popupId).popup('close');
JavaScript/JQuery: Open/Close Popup

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s