Apply jquery mobile only a portion of page?

后端 未结 1 1280
别跟我提以往
别跟我提以往 2021-01-21 12:24

I have a sample page which we have design very well. Now, we need to use jquery mobile only a portion of our page. The problem is that, when I add jquery mobile it is messing al

相关标签:
1条回答
  • 2021-01-21 13:00

    There are several ways of achieving this, and you can find them in my other ARTICLE, or find it HERE. Search for chapter called: Methods of markup enhancement prevention.

    And here's a short description with examples. There are several solutions and you will need to pick right one:

    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).one("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.page.prototype.options.keepNative = "select, input";
       });    
      

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

    0 讨论(0)
提交回复
热议问题