0

jquery モバイルと一緒に Phonegap/cordova を使用しています。以下のコードを Chrome ブラウザーで実行すると、期待どおりに動作します。しかし、アプリケーションをビルドして Xcode iPhone シミュレーターで実行しようとすると、問題が発生します。最初のページ (json の解析 + 結果の表示) は正常に動作しますが、項目をクリックして詳細ページに移動できません。これを修正する方法について何かアドバイスはありますか?

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
         <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">
           <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
           <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
           <meta name="viewport" content="width=device-width, initial-scale=1">

            <style>
                .custom_listview_img {
                    margin:0px; 
                    padding:0px;
                    background-repeat:no-repeat;
                    background-size:100%;
                    height:150px;
                }
                ul {list-style : none; padding:0px;}
            </style>

            <script>
                $(document).on('click','.changePageButton', function() {
                    $.mobile.changePage("#page2");
                });
            </script>

            <script type="text/javascript">

      $(document).ready(function(){
        var url='http://api.yipit.com/v1/deals/?key=mRSTBQsB49CdMXTW&division=san-francisco&tag=restaurants&lat=37.871087&lon=-122.270913&callback=?';

            $.getJSON(url,function(json){
              $.each(json.response.deals,function(i,item){

                 $("#results").append('<ul data-role="listview" data-inset="true" data-theme="d" data-divider-theme="a" style="white-space:normal"><a class = "changePageButton" data-transition="slide"><li data-role="list-divider" role="heading" class="ui-li ui-li-divider ui-btn ui-bar-c ui-corner-top">'+item.business.name+'</li><li class="custom_listview_img" style = "background-image:url('+item.images.image_smart+');"></li></a></ul>');

              });
            });   

      });

    </script>
        <title>Hello</title>
    </head>
    <body>
            <div data-role="page" data-theme="c"> 

            <div data-role="header" data-theme="b"> 
                   <h1>Dealoka</h1> 
            </div> 

             <div data-role="content" id = "results">
                <!-- Display results of parsing json here -->
             </div>   

        </div> 



    <div data-role="page" id="page2" data-add-back-btn="true">
       <div data-role="header" data-theme="b">
          <h1>Page 2</h1>
       </div>
       <div data-role="content">
          <p>Deal details</p>
       </div> 
    </div>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>
    </body>
</html>
4

1 に答える 1

0

vclickの代わりにイベントを使用できますclick

詳細はこちら: http://api.jquerymobile.com/vclick/

于 2013-07-30T13:27:05.497 に答える