Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
68
rated 0 times [  72] [ 4]  / answers: 1 / hits: 36968  / 11 Years ago, sat, april 13, 2013, 12:00:00

I chose jQuery Mobile over other frameworks for its animation capabilities and dynamic pages support.



However, I'm running into troubles with styling. I'd like to keep the basic page style in order to perform page transitions. But I also need to fully customize the look'n feel of headers, listviews, buttons, searchboxes... Dealing with colors only is not enough. I need to handle dimensions, positions, margins, paddings, and so on.



Therefore I struggle with extra divs and classes added by jQuery Mobile in order to override them with CSS. But it is so time-consuming, and it would be way faster to rewrite css from scratch...



Is there a way to load a minimal jQuery Mobile css file ?



Or should I look towards an other mobile framework ? I need to handle page transitions, ajax calls, Cordova compatibility, and of course a fully customizable html/css...


More From » html

 Answers
127

Methods of markup enhancement prevention:



This can be done in few ways, sometimes you will need to combine them to achieve a desired result.




  • Method 1:



    It can do it by adding this attribute:



    data-enhance=false


    to the header, content, footer container.



    This also needs to be turned in the app loading phase:



    $(document).on(mobileinit, function () {
    $.mobile.ignoreContentEnabled=true;
    });


    Initialize it before jquery-mobile.js is initialized (look at the example below).



    More about this can be found here:



    http://jquerymobile.com/test/docs/pages/page-scripting.html



    Example: http://jsfiddle.net/Gajotres/UZwpj/



    To recreate a page again use this:



    $('#index').live('pagebeforeshow', function (event) {
    $.mobile.ignoreContentEnabled = false;
    $(this).attr('data-enhance','true');
    $(this).trigger(pagecreate)
    });

  • Method 2:



    Second option is to do it manually with this line:



    data-role=none


    Example: http://jsfiddle.net/Gajotres/LqDke/


  • Method 3:



    Certain HTML elements can be prevented from markup enhancement:



     $(document).bind('mobileinit',function(){
    $.mobile.keepNative = select,input; /* jQuery Mobile 1.4 and higher */
    //$.mobile.page.prototype.options.keepNative = select, input; /* jQuery Mobile 1.4 and lower */
    });


    Example: http://jsfiddle.net/Gajotres/gAGtS/



    Again initialize it before jquery-mobile.js is initialized (look at the example below).




Read more about it in my other tutorial: jQuery Mobile: Markup Enhancement of dynamically added content


[#78936] Thursday, April 11, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorr

Total Points: 193
Total Questions: 86
Total Answers: 105

Location: Pitcairn Islands
Member since Thu, Jun 24, 2021
3 Years ago
victorr questions
Fri, Nov 13, 20, 00:00, 4 Years ago
Sat, Jul 25, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;