Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap NativeControls not working
    primarykey
    data
    text
    <p>I've read and followed tutorials on this site or the web on how to add the NativeControls plugin to PhoneGap (Cordova 1.5) with Jquery Mobile. I haven't been able to get the toolbar to work properly.</p> <p>I've tried many different things with no luck. Here is my code:</p> <p>html:</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;!--&lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /&gt;--&gt; &lt;meta name="viewport" content="width=device-width,initial-scale=1"/&gt; &lt;link rel="stylesheet" href="jquery/jquery.mobile-1.0.1.min.css"/&gt; &lt;script src="jquery/jquery-1.6.4.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="styles.css"/&gt; &lt;script src="jquery/jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt; &lt;title&gt;&lt;/title&gt; &lt;!-- iPad/iPhone specific css below, add after your main css &gt; &lt;link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" /&gt; &lt;link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" /&gt;--&gt; &lt;!-- If your application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here --&gt; &lt;script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"&gt;&lt;/script&gt; &lt;script src="NativeControls.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;script src="js/main.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body onload="onBodyLoad()"&gt; &lt;div data-role="page" id="mainpage"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;LOGIN&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;img src="images/cslogosmall2.png" style="margin-top: -10px; margin-left: -5px;"/&gt; &lt;form id="login" method="post"&gt; &lt;p&gt; &lt;ul data-role="listview" data-theme="g" id="contentlist"&gt; &lt;b&gt;Program:&lt;/b&gt; &lt;input type="text" id="program"/&gt; &lt;b&gt;Username:&lt;/b&gt; &lt;input type="text" id="username"/&gt; &lt;b&gt;Password:&lt;/b&gt; &lt;input type="password" id="password"/&gt; &lt;/ul&gt; &lt;/p&gt; &lt;br/&gt; &lt;button type="submit" data-theme="a" id="submit" value="Submit"&gt;&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;!--&lt;div data-role="footer"&gt; &lt;h1&gt; Main Page Footer &lt;/h1&gt; &lt;/div&gt;--&gt; &lt;/div&gt; &lt;div data-role="page" id="contentpage"&gt; &lt;div data-role="header"&gt; &lt;h1&gt; Content Page &lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;a href="#" data-role="button" onclick="history.go(-1);return false;" onClick=buttonDemo()&gt; Back to Main Page &lt;/a&gt; &lt;a href="#" data-role="button" id="beepbtn" onClick=beepbeep()&gt; Beep!&lt;/a&gt; &lt;/div&gt; &lt;div data-role="footer"&gt; &lt;h1&gt; Content Page Footer &lt;/h1&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>main.js:</p> <pre><code>function onBodyLoad() { $('#submit').click(function() { var program = document.getElementById('program').value; var username = document.getElementById('username').value; var password = document.getElementById('password').value; if (!program || program == "") { alert("Please enter a program"); return false; } else if (!username || username == "") { alert("Please enter a username"); return false; } else if (!password || password == "") { alert("Please enter a password"); return false; } return true; }); document.addEventListener("deviceready", onDeviceReady, false); } /* When this function is called, Cordova has been initialized and is ready to roll */ /* If you are supporting your own protocol, the var invokeString will contain any arguments to the app launch. see http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html for more details -jm */ function onDeviceReady() { // Initializating TabBar navigator.notification.alert("Cordova is working"); nativeControls = window.plugins.nativeControls; navigator.notification.alert(nativeControls); nativeControls.createTabBar(); // Books tab nativeControls.createTabBarItem( "books", "Books", //"/www/tabs/book.png", "", {"onSelect": function() { books(); }} ); // Stats tab nativeControls.createTabBarItem( "finished", "Finished", //"/www/tabs/box.png", "", {"onSelect": function() { finished(); }} ); // About tab nativeControls.createTabBarItem( "about", "About", //"/www/tabs/info.png", "", {"onSelect": function() { about(); }} ); // Compile the TabBar nativeControls.showTabBar(); nativeControls.showTabBarItems("books", "finished", "about"); nativeControls.selectTabBarItem("books"); } function books() { } function about() { } function finished(){ } </code></pre> <p>As you can see, I do a:</p> <pre><code> navigator.notification.alert("Cordova is working"); nativeControls = window.plugins.nativeControls; navigator.notification.alert(nativeControls); nativeControls.createTabBar(); </code></pre> <p>to test if nativeControls variable has anything in it. I don't get any alerts. I even tried:</p> <pre><code>navigator.notification.alert(window); </code></pre> <p>with no luck. I've added the NativeControls key to Cordova.plist as NativeControls - NativeControls.</p> <p>Any help would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload