user3422998
user3422998

Reputation: 105

jQuery mobile on click function

I am just starting with jQuery Mobile I want to create popup.

I found the following example on the jQuery Mobile site:

<a href="#popupBasic" data-rel="popup">Open Popup</a>
<div data-role="popup" id="popupBasic">
    <p>This is a completely basic popup, no options set.<p>
    <a href="index.html" data-role="button">Link button</a> 
    <a href="index.html" data-role="button">Link button</a> 
</div>

That works very well. What I need now is to change that from an href to an onClick function like this below:

<a href="#" onclick="popupBasic" data-rel="popup">Open Popup</a>

Its not working like that. What should I put to onClick to make it work?

Really appreciate your help.

Upvotes: 0

Views: 79

Answers (1)

Butani Vijay
Butani Vijay

Reputation: 4239

You can use as below:

Create javascript function :

 function openPopUp(){
        $('#popupBasic').popup('open'); 
    }

call openPopUp() in click event as below :

<a href="#" onclick="openPopUp()" data-rel="popup">Open Popup</a>

JSFiddle

Upvotes: 1

Related Questions