开发者

How can I run javascript in different pages using Jquery mobile?

It seems that after transitioning to a new page, the javascript cannot be ran. Since most decent client apps now involve lots and lots of JavaScript, was is the general preferred 开发者_运维知识库pattern for Jquery mobile and using javascript within each page?


all JavaScript should be in the root page. so if index.html is your home page put all the JavaScript in that page


You can bind to the pageshow event and run jquery code depending on when the page is shown:

$(document).ready(function(){           
    $('div').live('pageshow', function () { 
        if(this.id=="months.html"){
            //Page specific to a page div with "months.html" id
            alert("The month.html page was just shown");
        }
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜