title: Access Phonegap API from Backbone.js model
body: <p>I'm developing an app with backbone.js, require.js and Phonegap. I'm having problems accessing the Phonegap api from the Model. My index.html file looks like this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"/&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"&gt;
  &lt;link href="topcoat/css/topcoat-mobile-light.min.css" rel="stylesheet"&gt;
  &lt;link href="css/styles.css" rel="stylesheet"&gt;
  &lt;link href="css/pageslider.css" rel="stylesheet"&gt;
  &lt;script type="text/javascript" src="cordova.js"&gt;&lt;/script&gt;
  &lt;script data-main="js/app" src="js/require.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;&lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>In the initialize function of the router, I'm testing the Phonegap API:</p>
  
  <pre><code>    initialize: function() {
  
  
          window.localStorage.setItem("key", "some bloddy value");
          var value = window.localStorage.getItem("key");
  
          console.log('the value is');
          console.log(value);
  }
  </code></pre>
  
  <p>This works fine, I can get that the value is set and is retrieved. I also have a logged in status model. This is as follows:</p>
  
  <pre><code>define(function (require) {
  
  "use strict";
  
  var $                   = require('jquery'),
      Backbone            = require('backbone'),
  
  
      LoginStatus = Backbone.Model.extend({
  
          defaults: {
             loggedIn: false,
             api_key: null,
             user_id: null
         },
  
         initialize: function () {
  
          window.localStorage.setItem("key2", "some other value");
          var value = window.localStorage.getItem("key2");
          console.log('in init, the value is');
          console.log(value);
         },
  
      });
  
  return {
      LoginStatus: LoginStatus
  };
  
  });
  </code></pre>
  
  <p>When I call instantiate model from the initialize function of the router, I get the error:</p>
  
  <pre><code>Uncaught illegal access at file:///android_asset/www/js/app/models/loginstatus.js
  </code></pre>
  
  <p>How can I access Phonegap api from my models?</p>