Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created March 22, 2011 17:39
Show Gist options
  • Select an option

  • Save ahoward/881652 to your computer and use it in GitHub Desktop.

Select an option

Save ahoward/881652 to your computer and use it in GitHub Desktop.

Revisions

  1. ahoward created this gist Mar 22, 2011.
    31 changes: 31 additions & 0 deletions a.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@

    jq('div').live('pagebeforeshow', function(event, ui){
    var page = jq(event.target);

    var url = page.attr('data-refresh');

    if(url){
    var ajax = {};
    ajax.url = url;
    ajax.type = 'GET';
    ajax.cache = false;
    ajax.data = {'refresh' : true };
    ajax.async = false;

    ajax.success = function(data){
    var hidden = jq(data).hide().appendTo(jq.mobile.pageContainer);
    html = hidden.html();

    page.html(html);

    // TODO - how to properly initialize the page?
    //
    page.page();

    var all = jq("<div></div>");
    all.get(0).innerHTML = html; // force <script> tags to fire...
    };

    jq.ajax(ajax);
    };
    });