开发者

JQ Mobile - Transitioning BACK to a page & want to do something but can't figure out what event to call

开发者 https://www.devze.com 2023-04-12 08:13 出处:网络
On my main page, when it goes live $(\'#mainPage\').live(\'pagecreate\', function (event) { if (window.openDatabase) {

On my main page, when it goes live

$('#mainPage').live('pagecreate', function (event) {

    if (window.openDatabase) {
        //createDatabase();
        //etc

I list a table out to the screen... I have a Maintenance button/page that allows me to edit, delete some entries.

I want to be able to re-list that table on the main page when I click BACK from my maintenance page (since that table has most likely开发者_StackOverflow中文版 changed) but I cannot figure out what event is called when a page is transitioned too...

Nothing happens in the .live('pagecreate' -- event... I tried pageinit... I am missing something here.

Help?


Here's what I found:

  1. I was using the data-rel="back" on my button which kept taking me to index.html rather than the div name (#mainPage)... so I removed the back behavior because I really didnt need it. (not sure what I would do if I did)
  2. read more of the jq mobile docs (imagine that) and found this rather verbose way:

    $(document).bind("pagebeforechange", function (e, data) {

        // We only want to handle changePage() calls where the caller is
        // asking us to load a page by URL.
        if (typeof data.toPage === "string") {
    
            // We are being asked to load a page by URL, but we only
            // want to handle URLs that request the data for a specific
            // category.
            var u = $.mobile.path.parseUrl(data.toPage);
            var re = /^#mainPage/;
    
            if (u.hash.search(re) !== -1) {
                listZooAnimals();
            }
        }
    });
    

This just feels like serious overkill and that I might still be missing some easier way of doing this.

0

精彩评论

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