title: Cordova SQLite plugin only works on first call
body: <p>I have a cordova app with two pages, the first has a search field and the second displays the results of the first.
  The <code>displayResults</code> function</p>
  
  <pre><code>function displayResults(){
      var query = localStorage.getItem('search');
      var db = window.sqlitePlugin.openDatabase({name:"Store-DB", location: 1});
      queryDB(db,query);
      }
  
  function queryDB(db,query){
      db.transaction(function(tx) {
              var queryList = query.split(" ");
              var sqlText = "SELECT * FROM DB WHERE item LIKE '%"+queryList[0]+"%'";
              for (i = 1; i &lt; queryList.length; i++) {
                      sqlText += " OR item LIKE '%"+queryList[i]+"%'";
              }
              tx.executeSql(sqlText, [], querySuccess);
          }
          );
      }
  
  function querySuccess(tx,results) {
      var i;
      var len = results.rows.length;
      //Iterate through the results
      for (i = 0; i &lt; len; i++) {
          console.log(row);
          //Get the current row
          var row = results.rows.item(i);
          var div = document.createElement("div");
          div.style.background = "gray";
          div.style.color = "white";
          div.innerHTML = row;
  
          document.body.appendChild(div);
      }
      alert("Finished");
  }
  </code></pre>
  
  <p>Here is the code for the second page:</p>
  
  <pre><code>    &lt;link rel="stylesheet" type="text/css" href="css/default.css"&gt;
      &lt;script type="text/javascript" charset="utf-8" src="cordova.js"&gt;&lt;/script&gt;
      &lt;script src="js/zepto.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="plugins/com.brodysoft.sqlitePlugin/www/SQLitePlugin.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/code.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function onLoad(){
              document.addEventListener("deviceready", onDeviceReady(), false);
          }
          function onDeviceReady(){
              displayResults();
          }
      &lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body onload="onLoad()"&gt;
          &lt;div id="taskbar"&gt;
              &lt;a href="index.html"&gt;Home&lt;/a&gt;
              &lt;a id="username" class="toolbar_item" style="float:right;"  href="#"&gt;&lt;/a&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>The first time you load this page <code>displayResults</code> works just fine, but if you click the link back to the main page and load the second page again the console prints the error <code>ReferenceError: no "undefined" has no property "openDatabase"</code> in other words, the SQLite plugin isn't loading. But, if I make <code>displayResults</code> fire on a button press instead of <code>onload</code> it works every time. What is the explanation for this peculiar behavior?</p>