Search code examples
jquery-mobilejsf-2primefacesmobile-website

How to enable ajax page load in primefaces mobile


How can we enable page-loading via ajax in primefaces-mobile. In jquery mobile, ajax page loading is by default, How to achieve this in primefaces-mobile[I read on primefaces website that primefaces mobile is powered by jquery mobile, then why doesn't it load the pages via ajax.].


Solution

  • By viewing the page-source of primefaces-mobile-web page, I found following clue

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

    Now all you have to do is to find a way to override mobileinit event, and set the above variables to true. I simply included following script in my h:head tag:

    $.mobile.ajaxEnabled = true;
    $.mobile.linkBindingEnabled = true;
    $.mobile.hashListeningEnabled = true;
    $.mobile.pushStateEnabled = true;
    

    This served my purpose, but I am afraid, this might affect primefaces-mobile controls behaviour e.g. form submission.