jQuery移动数据角色滑块不起作用

问题描述:

我正在使用最新的jQuery移动1.0.1,我在第二页上使用data-role =滑块,该页面在从第一页过渡之后加载。这个数据角色滑块似乎不适用于第二页。当我独立运行该页面时,它可以工作,但不会在从第一页转换后加载。我也检查了调试也没有JavaScript错误。任何帮助,将不胜感激。jQuery移动数据角色滑块不起作用

+0

你在第二页上使用data-role =“page”吗?你可以发布你的第一页代码吗? – DG3 2012-02-25 04:16:54

找到下面的代码。这对我来说可以。

<!DOCTYPE html> 
<html class="ui-mobile-rendering"> 

<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Single page template</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script> 
</head> 


<body> 

<div data-role="page" id="one"> 

    <div data-role="header"> 
     <h1>Single page</h1> 
    </div><!-- /header --> 

    <div data-role="content"> 
     <p>This is a single page boilerplate template that you can copy to build you first jQuery Mobile page. Each link or form from here will pull a new page in via Ajax to support the animated page transitions.</p>  
     <p>Just view the source and copy the code to get started. All the CSS and JS is linked to the jQuery CDN versions so this is super easy to set up. Remember to include a meta viewport tag in the head to set the zoom level.</p> 

     <p>This template is standard HTML document with a single "page" container inside, unlike a <a href="multipage-template.html" data-ajax="false">multi-page template</a> that has multiple pages within it. We strongly recommend building your site or app as a series of separate pages like this because it's cleaner, more lightweight and works better without JavaScript.</p> 
       <p><a href="#two" data-role="button">Show page "two"</a></p>  
     </div><!-- /content --> 

    <div data-role="footer"> 
     <h4>Footer content</h4> 
    </div><!-- /footer --> 

</div><!-- /page --> 

<!-- Start of second page: #two --> 
<div data-role="page" id="two" data-theme="a" data-transition="slider"> 

    <div data-role="header"> 
     <h1>Two</h1> 

    </div><!-- /header --> 

    <div data-role="content" data-theme="a"> 
       <label for="flip-a">Select slider:</label> 
       <select name="slider" id="flip-a" data-role="slider"> 
         <option value="off">Off</option> 
         <option value="on">On</option> 
       </select> 
     <h2>Two</h2> 
     <p>I have an id of "two" on my page container. I'm the second page container in this multi-page template.</p> 
     <p>Notice that the theme is different for this page because we've added a few <code>data-theme</code> swatch assigments here to show off how flexible it is. You can add any content or widget to these pages, but we're keeping these simple.</p> 
     <p><a href="#one" data-direction="reverse" data-role="button" data-theme="b">Back to page "one"</a></p> 

    </div><!-- /content --> 


    <div data-role="footer"> 
     <h4>Page Footer</h4> 
    </div><!-- /footer --> 
</div><!-- /page two --> 
</body> 
</html> 
+0

它仍然不适合我。 – user1232072 2012-02-25 05:52:57

+0

它可以帮助你发布你的代码。 – DG3 2012-02-25 05:56:26