JQuery popup.(“open”) not working

安稳与你 提交于 2019-12-08 13:42:42

问题


I'm trying to open a popup window as soon as my page gets load with the help of .ready() function and below is the code within it. But the function below is not giving any response. Any other way to open jquery popups on page load??

if( access_token==""&&access_token==null)
                 {
$( "#popupDialog1" ).popup( "open" )
}

The above code is integrated for an android app to be devloped using phonegap,html5,javascript etc


回答1:


I think you should use || instead of && beacuse a variable can't be empty and null in the same time

if( access_token=="" || access_token==null){
    $( "#popupDialog1" ).click();             //try with click()
}



回答2:


There is no such thing in jQuery or jQueryUI, it's a jQueryMobile method.

So the problem you're currently facing probably have something to do with the fact that you didn't initialize the popup before.

Try this (use the two lines).

$( "#popupDialog1" ).popup();
$( "#popupDialog1" ).popup( "open" );

You can also play with this jsBin http://jsbin.com/laceboni/1/




回答3:


Check the undefined for access_token.

access_token == undefined

And change the logical operator from && to || as you are checking two values for same variable at same time.

if( access_token=="" || access_token==null || access_token==undefined)
{
     $( "#popupDialog1" ).popup( "open" )
}


来源:https://stackoverflow.com/questions/23362241/jquery-popup-open-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!