Note that there are some explanatory texts on larger screens.

plurals
  1. POcan't find $ - while using JQueryMobile and IBM Worklight 6.0
    primarykey
    data
    text
    <p>I am trying to integrate a bar code scanner onto a phone gap app developed on worklight, the current html page comes from a href from the main page like this.</p> <pre><code>&lt;a data-role="button" href="itemscan.html" rel="external" data-shadow="false" data-theme="none"&gt;&lt;img src="images/dashboard_barcode.png" &gt;&lt;/a&gt; </code></pre> <p>My html Page:</p> <p> <pre><code> 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. --&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;BarCode Scanner&lt;/title&gt; &lt;link rel="stylesheet" href="jqueryMobile/jquery/jquery.mobile-1.3.2.css"&gt; &lt;script src="jqueryMobile/jquery/jquery.mobile-1.3.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="app"&gt; &lt;h1&gt;Zxing Scanner!!&lt;/h1&gt; &lt;div id="deviceready" class="blink"&gt; &lt;p class="event listening"&gt;Connecting to Device&lt;/p&gt; &lt;p class="event received"&gt;Device is Ready&lt;/p&gt; &lt;p id="barcoderesult"&gt;Bar Code Result: Nil&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript" src="js/cordova-2.5.0.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="modules/core/CoreFunc.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/barcodescanner.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/itemscan.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/MenuPanel.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; app.initialize(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>JS file:</p> <pre><code>/* * 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. */ var app = { // Application Constructor initialize: function() { this.bindEvents(); }, // Bind Event Listeners // // Bind any events that are required on startup. Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicity call 'app.receivedEvent(...);' onDeviceReady: function() { app.receivedEvent('deviceready'); // demo the scan console.log('about to scan'); try { var scanned = app.scan(); console.log('scan triggered', scanned); } catch (e) { console.log('scan failed'); console.log(JSON.stringify(e)); console.log('that sucks... reloading in 10'); setTimeout(function() { console.log('reloading now...'); app.onDeviceReady(); }, 10000); } }, // Update DOM on a Received Event receivedEvent: function(id) { var parentElement = document.getElementById(id); var listeningElement = parentElement.querySelector('.listening'); var receivedElement = parentElement.querySelector('.received'); listeningElement.setAttribute('style', 'display:none;'); receivedElement.setAttribute('style', 'display:block;'); console.log('Received Event: ' + id); }, /** * here is an example for scanning a barcode... * obviously, your own JS logic &lt;&lt;here&gt;&gt; * * Note the require() method is called on window.cordova * this is different than the readme! */ scan: function() { console.log('scan(): init'); // documentation said the syntax was this: // var scanner = window.PhoneGap.require("cordova/plugin/BarcodeScanner"); // but playing with options, seems like it should be this: var scanner = window.cordova.require("cordova/plugin/BarcodeScanner"); scanner.scan( function (result) { var parentElement = document.getElementById("barcoderesult"); parentElement.innerHTML = result.text; // alert("We got a barcode\n" + // "Result: " + result.text + "\n" + // "Format: " + result.format + "\n" + // "Cancelled: " + result.cancelled); console.log("We got a barcode\n" + "Result: " + result.text + "\n" + "Format: " + result.format + "\n" + "Cancelled: " + result.cancelled); $.mobile.changePage( "../itemDetails.html", { transition: "slideup", changeHash: false }); }, function (error) { alert("Scanning failed: " + error); } ); } }; </code></pre> <p>The scanning works fine, after a success callback I get the bar code and then I get this, I am not able to do changePage.</p> <blockquote> <p>[LOG] Error in error callback: BarcodeScanner957715450 = ReferenceError: Can't find variable: $</p> </blockquote> <p>From all the searching I have done, I have found that the jQuery is not loaded properly. I am kinda new to all these web technologies so any help is 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.
    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