jQuery的移动。 无法以编程方式打开对话框; 尝试了我能想到的一切

我想以编程方式打开一个jquery-mobile对话框。 我试着做:

$("#jenia-dialog").dialog() #("jenia-dialog").dialog("open") Error: no such method 'open' for dialog widget instance 

这是我的html文件:

    Page Title       

Dialog

Is this an answer?

这是我的jsfiddle页面: http : //jsfiddle.net/kK24p/

我想要做的就是使用js而不是按钮打开对话框。

如果有人能帮助我,那就太好了。

非常感谢提前。

工作实例:

解决方案1

第1页: – index.html

    Page Title      

Sample

第2页: – https://stackoverflow.com/questions/24071669/jquery-mobile-cant-open-the-dialog-programmatically-tried-everything-i-could/dialog.html

 

Dialog

This is dialog content

解决方案2

    Page Title       

Sample

Dialog

This is dialog content

以编程方式打开对话框的正确方法需要changePage函数,如下所示:

 $.mobile.changePage("#jenia-dialog", {transition: 'pop', role: 'dialog'}); 

如果您需要打开外部对话框,同样的事情:

 $.mobile.changePage("https://stackoverflow.com/questions/24071669/jquery-mobile-cant-open-the-dialog-programmatically-tried-everything-i-could/dialog.html", {transition: 'pop', role: 'dialog'}); 

我对您的代码做了几处更改,请参考它。 我删除了在第一页中打开div

的结束标记。 它是有线的,但将来解决它,下一点是你不能在弹出窗口中加载这样的外部页面。 请参阅此链接如何在JQM弹出窗口中加载外部页面

 

Sample

Dialog

Is this an answer?