开发者

how to put timeout on jquery mobile dialog?

this is my js that calls the div and displays it as a dialog:

$.mobile.changePage('#answerResult',{transition:'slide', role:'dialog'});

and this is the div

<div data-role="page" id="answerResult" data-r开发者_运维问答ole="page">
  <div data-role="header" data-backbtn="false">
    <h1>Pop me up</h1>
  </div>
  <div data-role="content">
    Content
  </div>
</div>

Is it possible to create a timeout for the dialog so that it will autoclose after specified time? I have searched google for this but I can't seem to find any answers that fits into what I want.

Many thanks for your help.


Yes, after your line with changePage, add:

window.setTimeout(function(){ /* code to close dialog here */ }, 1000);

Here's the docs for window.setTimeout

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜