JQuery Mobile Ajax (JS не выполняется) - PullRequest
1 голос
/ 07 декабря 2010

Я китаец! У меня плохой английский, но у меня проблемы с JQuery Mobile! Надеюсь, что иностранный друг может помочь мне. Вопрос ниже!

first: На first.jsp нажмите кнопку «General» в порядке. Но кнопка «Submit» не в порядке. Почему ?? секунда: нажмите кнопку «Ссылка», перейдите к second.jsp, нажмите кнопку «Тест». Код JavaScript не выполняется!

Я не знаю, почему они случаются! Вы можете мне помочь! Спасибо.

first.jsp

<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
 <head>
        <title>China</title>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.css" />
        <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery-1.4.4.js"></script>
        <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.js"></script>
        <script>
            $(function(){
                $('#Button').click(function(){
                    alert('This is a general button!');
                });
                $('#ButtonSubmit').click(function(){
                    alert('This is a submit button!');
                });
            });
        </script>
    </head>
    <body>
        <div id="page" data-role="page" data-theme='d'>
            <div data-role="header" data-position="inline" data-position="fixed">
                <h1>Chinese</h1>
            </div>
            <div data-role="content">
                <a id="Button" data-role='button' data-iconpos="right" data-icon="gear">General Button</a>
                <a id="ButtonSubmit" data-role='button' data-iconpos="right" type="submit" data-icon="gear">Submit Button</a>
                <a id="link" href="/mobile/mobile/second.jsp" data-role='button' data-iconpos="right" data-icon="gear">Link Button</a>
            </div>
            <div data-role="footer" data-position="fixed">
                <h1>[Email:zhaosheng.wolf@163.com][1]</h1>
            </div>
        </div>
    </body>
</html>

second.jsp

<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
 <head>
        <title>China</title>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.css" />
        <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery-1.4.4.js"></script>
        <script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.js"></script>

        <script>
            $(function(){
                $('#test').click(function(){
                    alert('This is a general button!');
                });
            });
        </script>
    </head>
    <body>
        <div id="page" data-role="page" data-theme='d'>
            <div data-role="header" data-position="inline" data-position="fixed">
                <h1>[Chinese][2]</h1>
            </div>
            <div data-role="content">
                <a id="test" data-role='button' data-iconpos="right" data-icon="gear">Test</a>
            </div>

            <div data-role="footer" data-position="fixed">
                <h1>Email:zhaosheng.wolf@163.com</h1>
            </div>
        </div>
    </body>
</html>


  [1]: http://zhaosheng.wolf@163.com
  [2]: http://zhaosheng.wolf@163.com

Ответы [ 2 ]

1 голос
/ 07 декабря 2010

Удалить type="submit" in #ButtonSubmit

А если вам нравится стиль вашей кнопки, чтобы она выглядела как кнопка, взгляните на her .

0 голосов
/ 09 марта 2011

JQuery Mobile использует ajax для изменения страницы, и вам нужно использовать live () или делегат () для события «pageshow» или другого для запуска при вызове этого события.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...