localStorageApp is not defined

2 posts, 1 answers
  1. XiMnet Malaysia
    XiMnet Malaysia avatar
    46 posts
    Member since:
    Jan 2006

    Posted 11 Nov 2014 Link to this post


    Was trying to use localStorageApp as below, but in the emulator debugger, I get error : Uncaught ReferenceError: localStorageApp is not defined.
    What am I missing?

    var app = {
        // Application Constructor
        initialize: function() {
        // 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() {
              localStorageApp = new localStorageApp();
        // 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);
  2. Answer
    Kaloyan avatar
    871 posts

    Posted 14 Nov 2014 Link to this post

    Hi XiMnet Malaysia,

    I am not sure if I have fully understood your inquiry, so, please correct me if needed.

    In order to use Local Storage in hybrid apps, you need to access the localstorage object, instead of localStorageApp. For example, like this:
    onDeviceReady: function() {
        localStorage.setItem("lastname", "Smith");
    More about local storage, can be found in the Cordova documentation or here. You can also check the AppBuilder's Local Storage sample.

    Further, if the localStorageApp is an object, different than the webview's local storage, I suggest to check if it is set on global level, or if the needed references are present in order to access it.

    I hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top