如何在页面加载时打开对话框 [英] How to open a Dialogue Box On Page Load

查看:191
本文介绍了如何在页面加载时打开对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开一个对话框在页面加载jquery手机屏幕。现在我可以打开对话框上的按钮单击。我想让对话框自动弹出页面加载,但不能做它。
这是HTML ..

I am trying to open a Dialogue Box On page load of jquery Mobile screen .Right now i am able to open Dialogue Box on button Click .I want the Dialogue box to get pop up automatically on page load but not able to do it. Here is the HTML..

 <body onload="onLoad()">

 <p style="display: none>You have entered: <span id="dialogoutput"></span></p>

 <a href="#" id="dialoglink" data-role="button" style="display: none>Open Dialog</a>

 <!-- Contacts list page -->
 <div data-role="page" id="cont_list_page" data-theme="a">        
 <div data-role="header" data-position="fixed" data-tap-toggle="false">
 </div>
 </div>
 </body>

这是我的jquery ..

and Here is my jquery ..

function onLoad() { 
document.addEventListener("deviceready", onDeviceReady, false);
$("#searchby_chooser_ok_button").bind ("click", searchByCriteria); 

if (typeof Contact === "undefined") {
    getElement("contacts_list").innerHTML = "<p>The Cordova Contacts API is inaccessible</p>";
}
}

请帮助我弹出对话页不自动按钮单击事件。
感谢

Please help me to pop up the Dialogue on Page Load not on button click event automatically. Thanks

推荐答案

尝试使用 $(document).ready(function )

$(document).ready(function()
{
  $("#simplestring").simpledialog({
    'mode' : 'string',
    'prompt' : 'Please Enter Your Mobile No.',
    'buttons' : {
      'OK': {
        click: function () {
          $('#dialogoutput').text($('#dialoglink').attr('data-string'));

          //get the Value Entered 
          //Create a Sqlite Database and table 
          //Insert it there 

        }
      },
      'Cancel': {
        click: function () { },
        icon: "delete",
        theme: "c"
      }
    }
  })
});

这篇关于如何在页面加载时打开对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆