Thursday, 4 August 2011

jQuery - Delete cache with jQuery Mobile

This is function will help me delete cache when I build website for mobile:

$(function(){
    $('div').live('pagehide', function (event, ui) {
      var $this = $(this);
      if ($this.attr('ID') !== undefined && $this.attr('data-cache') !== undefined && $this.attr('data-cache') == "never") {
        var page = $this.attr('ID');
        $(document.getElementById(page)).remove();
      }
    });
});


OR

$(document).bind("mobileinit", function () {
    $.mobile.hashListeningEnabled = false;
    $.mobile.ajaxEnabled = false;
});


OR

$(document).ready(function() {
    $('form, a').removeAttr('data-ajax');
    $('form, a').attr('data-ajax', false);
});



Good luck!

No comments:

Post a Comment