###前提・実現したいこと
monaca開発初心者です。
タブ切り替えと同時にjqueryイベントを発火させようとしていますが、以下のエラーが表示されうまく動作しません。
解決方法についてご教示いただけないでしょうか。
また、アプリの起動時に②の警告が表示されます。jquery-mobileを読み込まずに実行すると表示されません。
初心者のため、説明不足な点があるかもしれませんが、お許し下さい。
**
※2017年11月16日18時追記**
試しに新規プロジェクトで「Onsen UI V2 JS Tabbar」を作成し、その後、loaderにjquerymobileを追加して動作させたところ、同様の現象が発生しました。
jqueryイベントを動作させようとすると①と同様のエラーが発生します。
monaca側の不具合なのでしょうか。
現在monaca無料プランで実機デバッグを実行していますが、こういった事情も関係するのでしょうか。
何かご存じの方がおりましたら情報お待ちしています。
###発生している問題・エラーメッセージ
①エラー
Uncaught(in promise) TypeError: Cannot set property 'checked' of null
②警告メッセージ
ons-template (id = templateEdit.html) must be located just under document.body: <div data-role="page"> <ons-page class="page page--material" modifier="material"><div class="page__background page--material__background" style="background-color: transparent;"></div><div class="page__content page--material__content" style=""> <ons-tabbar position="bottom" modifier="material" activeindex="1"><div class="tabbar__content ons-tabbar__content tabbar--material__content ons-swiper" style="touch-action: pan-y; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><div class="ons-swiper-target" style="transform: translate3d(-360px, 0px, 0px);"><div style="height: 100%; width: 100%; background-color: transparent;"></div><div style="height: 100%; width: 100%; background-color: transparent;"></div><div style="height: 100%; width: 100%; background-color: transparent;"></div></div><div class="ons-swiper-blocker"></div></div><div class="tabbar ons-tabbar__footer ons-swiper-tabbar tabbar--material"> <ons-tab label="画像入力" page="imageInput.html" icon="download" modifier="material" ripple="" class="tabbar__item tabbar--material__item"><input type="radio" style="display: none;"><button class="tabbar__button tabbar--material__button"><ons-ripple modifier="material" class="ripple--material"></ons-ripple><div class="tabbar__icon"><ons-icon modifier="material" class="ons-icon fa fa-download" icon="download"></ons-icon></div> <div class="tabbar__label">画像入力</div></button></ons-tab> <ons-tab label="画像一覧" page="imageList.html" icon="photo" active="" modifier="material" ripple="" class="tabbar__item tabbar--material__item active"><input type="radio" style="display: none;"><button class="tabbar__button tabbar--material__button"><ons-ripple modifier="material" class="ripple--material"></ons-ripple><div class="tabbar__icon"><ons-icon modifier="material" class="ons-icon fa fa-photo" icon="photo"></ons-icon></div> <div class="tabbar__label">画像一覧</div></button></ons-tab> <ons-tab label="テンプレート編集" page="templateEdit.html" icon="edit" modifier="material" ripple="" class="tabbar__item tabbar--material__item"><input type="radio" style="display: none;"><button class="tabbar__button tabbar--material__button"><ons-ripple modifier="material" class="ripple--material"></ons-ripple><div class="tabbar__icon"><ons-icon modifier="material" class="ons-icon fa fa-edit" icon="edit"></ons-icon></div> <div class="tabbar__label">テンプレート編集</div></button></ons-tab> <div class="tabbar__border tabbar--material__border" style="display: block; width: 120px; transition: all 0s; transform: translate3d(100%, 0px, 0px);"></div></div></ons-tabbar> </div></ons-page> <ons-template id="imageInput.html"></ons-template> <ons-template id="imageList.html"></ons-template> <ons-template id="templateEdit.html"></ons-template>
###該当のソースコード
index.html
<!DOCTYPE HTML> <html lang="ja"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'"> <script src="components/loader.js"></script> <script src="lib/onsenui/js/onsenui.min.js"></script> <script src="components/monaca-jquery/jquery.js"></script> <script src="components/monaca-jquery-mobile/jquery.mobile.js"></script> <script type="text/javascript" src="index.js"></script> <link rel="stylesheet" href="components/loader.css"> <link rel="stylesheet" href="lib/onsenui/css/onsenui.css"> <link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css"> <link rel="stylesheet" href="compenents/css/jquery.mobile.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <ons-page> <ons-tabbar position="bottom"> <ons-tab label="画像入力" page="imageInput.html" icon="download"> </ons-tab> <ons-tab label="画像一覧" page="imageList.html" icon="photo" active> </ons-tab> <ons-tab label="テンプレート編集" page="templateEdit.html" icon="edit"> </ons-tab> </ons-tabbar> </ons-page> <ons-template id="imageInput.html"> <ons-page id="imageInput"> <input type="button" value="push" onClick="getPhoto();"> <img id="picture" src="" width="150" height="150"> </ons-page> </ons-template> <ons-template id="imageList.html"> <ons-page id="imageList"> <ons-toolbar> <div class="center" id="toolbar-title"> <div class='center'> <button id="btn1" class="toolbar1Btn" type="button"> <p> <ons-icon size="1rem" icon="bolt" /> </p> <p>FTP送信</p> </button> <button id="btn2" class="toolbar1Btn" type="button"> <p> <ons-icon size="1rem" icon="envelope-o" /> </p> <p>メール送信</p> </button> <button id="btn3" class="toolbar1Btn" type="button"> <p> <ons-icon size="1rem" icon="tags" /> </p> <p>テンプレート適用</p> </button> </div> </div> </ons-toolbar> </ons-page> </ons-template> <ons-template id="templateEdit.html"> <ons-page id="templateEdit"> <p style="text-align: center;"> 編集テンプレートの編集画面の予定 </p> </ons-page> </ons-template> </body> </html>
index.js
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady () { window.alert ('Loading Cordova is completed'); } //アルバムから取得 function onSuccess(imageURI) { var largeImage = document.getElementById('picture'); largeImage.style.display = 'block'; largeImage.src = imageURI; } function getPhoto() { navigator.camera.getPicture(onSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM }); } function onFail(message) { alert('An error occured: ' + message); } $(document).on('pageshow', '#imageInput', function () { getPhoto(); })
回答2件
あなたの回答
tips
プレビュー