简体   繁体   中英

Popup a dialog use jquery mobile in phone gap

I'm developing a phonegap project, I wanna popup a dialog of error information. I learn some from the demos of jQuery mobile, here is the link http://demos.jquerymobile.com/1.4.0/popup/#&ui-state=dialog I used the code of it and in my js file I use popup('open') to open it.

Here is part of my html code

 <div data-role="popup" id="dialogZ" data-overlay-theme="b" data-theme="a" data-dismissible="false" data-transition="pop"> <div data-role="header" data-theme="b"> <h1 align="center">Sign in failed</h1> </div> <div role="main" class="ui-content"> <p id="SigninError"></p> <span align="center"><a href="#" class="ui-btn ui-corner-all ui-shadow" data-rel="back">OK</a></span> </div> </div> 

And here is part of my js code

else if (data == "Error2") {

    var message = '<p align="center">Wrong username or password</p>';
    SigninError.empty().append(message);
    $('#dialogZ').popup('open');
    }

I wanna have the effect like the demo but it didn't work.

Anyone knows why? It seems I can not have the css work properly, but I have included the jquery.mobile-1.4.0.css. Need helps!!

ya i got same issue before 4 months finally i got a solution. when you append content inside the popupview at the time u must call like this.....

JS

$('#dialogZ').popup();
$('#dialogZ').popup('open');

or

$('#dialogZ').popup();
setTimeout(function(){
$('#dialogZ').popup('open');
},100);

HTML

your data-role popup must inside the content of your calling page

Ideally data-transition should be on the link which triggers popup. since you are opening the popup in code, there is an additional attribute for $(dialog).open function, u need to pass the transition as part of open function., jquery doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM