Как я могу использовать jQuery Mobile для доступа к другой странице? - PullRequest
1 голос
/ 13 ноября 2010

Поначалу это может показаться глупым вопросом, но я не могу заставить jQuery загрузить другую страницу - когда я включаю ссылку:

<a href="test.html" data-pop >Go to the test page</a> 

Адрес (при условии, что мы пришли из index.html) просто получает # test.html, что означает, что конец моего адреса выглядит примерно так:

html/index.html#test.html

Мой вопрос: как мне загрузить другую страницу? Вот мой исходный код:

<!DOCTYPE html> 
<html> 
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
        <script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"</script>

         <title>Test</title>
     </head>
     <body>
         <div data-role="page"> 
             <div data-role="header"></div> 
             <div data-role="content">
                 <p>This is a test</p>
                 <a href="test.html" data-pop >Go to the test page</a> 
             </div> 
             <div data-role="footer"></div> 
         </div> 
     </body>
 </html>

1 Ответ

3 голосов
/ 13 ноября 2010

Ваш ответ задокументирован здесь . Этот скрипт, включенный между jquery и jquery mobile, работал:

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

Имейте в виду, что это не работает для jquery mobile 1.0a1, но работает с 1.0a2.

Итак, весь index.html будет выглядеть так:

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
        <script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
        <script type="text/javascript">
            $(document).bind("mobileinit", function() {
              $.mobile.ajaxLinksEnabled = false;
            });
        </script>
        <script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>

        <title>Test</title>
    </head>
    <body>
        <div data-role="page">
            <div data-role="header"></div>
            <div data-role="content">
                <p>This is a test</p>
                <a href="test.html" data-pop >Go to the test page</a>
            </div>
            <div data-role="footer"></div>
        </div>
    </body>
</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...