2

私は現在、Sencha Touch 2 に基づいたモバイル アプリケーションを構築しています。現時点では、Sencha の機能を確認するためにいくつかの実験を試みています。

そして今日、私は本当に奇妙に思えることに行き詰まりました。アプリケーションにjQueryライブラリを使用して、その追加機能を使用できるかどうか試してみたかっただけです。

最も奇妙なことは、jquery 関数を作成しているときに応答が得られないことです。

jquery ライブラリとスクリプトを sencha ディレクトリの index.html ファイルに含めました。単純なばかげたテスト スクリプトを作成して、それが機能するかどうかを確認しましたが、試してみてもまったく反応がありません。ブラウザで。ライブラリとスクリプトがfirebugを介して含まれていることがわかります(ご覧のとおり、私のjqueryテストはdivを表示する単純なクリックイベントですが、そうではありません)。

私はただのバカなのだろうか?

ここに私のindex.htmlファイルがあります

<!DOCTYPE HTML>
<html manifest="" lang="en-US">
<head>
<meta charset="UTF-8">
<title>scroller</title>

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function() {

        $("#show_me").click(function () {
            $('#magic').slideDown('slow');
        });

    });

</script>


<link rel="stylesheet" href="resources/css/sencha-touch.css" type="text/css">
<style type="text/css">
     /**
     * Example of an initial loading indicator.
     * It is recommended to keep this as minimal as possible to provide instant feedback
     * while other resources are still being loaded for the first time
     */
    html, body {
        height: 100%;
        background-color: #1985D0
    }

    #appLoadingIndicator {
        position: absolute;
        top: 50%;
        margin-top: -15px;
        text-align: center;
        width: 100%;
        height: 30px;
        -webkit-animation-name: appLoadingIndicator;
        -webkit-animation-duration: 0.5s;
        -webkit-animation-iteration-count: infinite;
        -webkit-animation-direction: linear;
    }

    #appLoadingIndicator > * {
        background-color: #FFFFFF;
        display: inline-block;
        height: 30px;
        -webkit-border-radius: 15px;
        margin: 0 5px;
        width: 30px;
        opacity: 0.8;
    }

    @-webkit-keyframes appLoadingIndicator{
        0% {
            opacity: 0.8
        }
        50% {
            opacity: 0
        }
        100% {
            opacity: 0.8
        }
    }
</style>
<!-- The line below must be kept intact for Sencha Command to build your application -->
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>
<!-- script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script--->
<script id="microloader" type="text/javascript" src="sdk/microloader/development.js"></script>
<!--<script type="text/javascript" src="app.js"></script>-->
<script type="text/javascript" src="js/cordova-1.7.0.js"></script>
<script type="text/javascript" src="js/phonegap_shortcuts.js"></script>
<script type="text/javascript" src="js/maps.js"></script>
<script type="text/javascript" src="js/zepto.min.js"></script>
<script type="text/javascript" src="js/filters.js"></script>
<script type="text/javascript" src="js/proxy.js"></script>
<!--<script type="text/javascript" src="js/index.js"></script>-->
<!--
<script type="text/javascript">
    document.addEventListener("deviceready", app.mainLaunch, false);
</script>
-->
<script type="text/javascript">
    function onDeviceReady() {
        pictureSource=navigator.camera.PictureSourceType;
        destinationType=navigator.camera.DestinationType;
    }
    function PictureSourceType() {};
    PictureSourceType.PHOTO_LIBRARY = 0;
    PictureSourceType.CAMERA = 1;
    //var ja = phonegap.shortcuts.getLocation();
    //console.log('ja:'+ja);
    document.addEventListener("deviceready", onDeviceReady, false);
</script>
    </head>
    <body>
    <div id="appLoadingIndicator">
    <div></div>
    <div></div>
    <div></div>
    </div>
    </body>
    </html>
4

1 に答える 1

0

クリックしている要素に「showme」という ID がない可能性があります。これは、Sencha で作成したボタンの ID が「showme」であるにもかかわらず、レンダリングされる実際の HTML には別の ID が含まれているために発生する可能性があります。

これが真の場合 (もちろん、FireBug を使用してこれを確認できます)、jQuery を使用して「クリック」イベントにバインドする代わりに、ボタンの「タップ」イベントをリッスンすることをお勧めします。ドキュメントについては、 http://docs.sencha.com/touch/2-0/#!/api/Ext.Button-event-tapを参照してください。

Sencha で jQuery を使用することは可能ですが、Sencha のコンポーネントは DOM の要素を直接表現したものではないことに注意してください。Sencha の一部のコンポーネントは、レンダリング時に複数の DOM 要素で構成されます。

お役に立てれば

于 2012-10-18T00:39:51.720 に答える