Question

What is the proper order for these scripts to be loaded?

This order has been the only one that I have found that properly populates the DB, however it throws the errors:

  • Uncaught Error: jQuery should be loaded before persistence.jquery.js
  • Uncaught Error: persistence.jquery.js should be loaded before persistence.jquery.mobile.js

I can re-order the scripts so that these errors do not appear, but I haven't found one that does not throw the errors && populates the DB correctly

Otherwise the DB is created correctly but when populating it, the entries are the default values instead of my custom iterated values

<head>  
  <script type="text/javascript" src="js/index.js"></script>
  <script type="text/javascript" src="lib/persistence.js"></script>
  <script type="text/javascript" src="lib/persistence.store.sql.js"></script>
  <script type="text/javascript" src="lib/persistence.store.websql.js"></script>
  <script type="text/javascript" src="lib/persistence.store.config.js"></script>
  <script>//population and clearance of DB scripst </script>
</head>
<body>
  <div class="app">...</div>
  <script type="text/javascript" src="lib/persistence.jquery.js"></script>
  <script type="text/javascript" src="lib/persistence.jquery.mobile.js"></script> 
  <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> 

  <script type="text/javascript">
    app.initialize();
  </script>
</body>
Was it helpful?

Solution

Use the demo/index.html file in the persistencejs src to answer this question. It has the jquery scripts first and persistencejs second. Here in the order in the demo file:

<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
<script src="http://code.google.com/apis/gears/gears_init.js"></script>
<script src="../../lib/persistence.js"></script>
<script src="../../lib/persistence.store.sql.js"></script>
<script src="../../lib/persistence.store.websql.js"></script>
<script src="../../lib/persistence.store.memory.js"></script>
<script src="../../lib/persistence.jquery.js"></script>
<script src="../../lib/persistence.jquery.mobile.js"></script>

Modify the order to use your own version and last I would loaded your database population script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top