Esri / quickstart-map-phonegap

ArcGIS JavaScript samples for use with PhoneGap/Cordova
35 stars 37 forks source link

ReferenceError: require is not defined #13

Closed sadiq-mc closed 8 years ago

sadiq-mc commented 8 years ago

Map is not loading when I tried by adding this script <script src="http://js.arcgis.com/3.14"></script> <script src="assets/js/jQueryHelper.js"></script>

andygup commented 8 years ago

Are you using one of the sample applications? If not, please try one of the sample applications and let me know if you are seeing the same problem.

sadiq-mc commented 8 years ago

Yes.. am using one of the examples..

On Mon, Mar 7, 2016 at 8:50 AM -0800, "Andy" notifications@github.com<mailto:notifications@github.com> wrote:

Are you using one of the sample applications? If not, please try one of the sample applications and let me know if you are seeing the same problem.

Reply to this email directly or view it on GitHubhttps://github.com/Esri/quickstart-map-phonegap/issues/13#issuecomment-193341089.

IMPORTANT NOTICE: This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.

sadiq-mc commented 8 years ago

I am trying using the example index_jquerymobilegps.html

andygup commented 8 years ago

Are you saying the unmodified sample app index_jquerymobilegps.html isn't working correctly? Can you please paste a screenshot of the console log?

ghost commented 8 years ago

The sample app is working fine... I said I used the same scripts mentioned above.

andygup commented 8 years ago

If the sample app works on the device, then there is an issue with your custom code.

Are you able to post your code and a screenshot of the console log?

ghost commented 8 years ago

I am using the same code mentioned in the comment here

Instead of dojo.js am using the below script <script src="http://js.arcgis.com/3.14"></script>

andygup commented 8 years ago

@sadiq-mc Sorry, I should have said it would be very helpful to see the entire application rather than just a snippet.

98% of the time require not defined errors are caused by problems within the application's life-cycle. The only way to find those is to look at all the code in the app.

Recommendation: make sure to delay running the require until after Cordova's deviceready event has fired. Example: basicmap.js

ghost commented 8 years ago

@andygup Just to mention, The require is invoked on map page load.. The script is invoked only at that time.. that means after deviceready is fired. The deviceready is called in index.js and the map's html & its javascript is invoked on a button click.

Am using a bunch of scripts in index.html and and do this get any conflict with map script.??? Below are the scripts loaded in index.html

<script src="js/jquery.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/inputmask.js"></script>
<script src="js/jquery.inputmask.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>

<!-- Custom scripts block -->
   ...........
<!-- Custom scripts ends -->
andygup commented 8 years ago

Recommendation 1: remove the script tag for phonegap.js or the one for cordova.js. We don't recommend running both phonegap and cordova at the same time and in the same app.

Recommendation 2: Make sure to mimic the life-cycle demonstrated in the jquery mobile sample. If you are following that sample, your application life-cycle will look like this PSUEDO-code:

<head>
   jquery css
   esri css
   jquery library
   jquery mobile library
</head>
<body>
   HTML
   dojo.js
   jQueryHelper.js
   cordova.js
</body>
andygup commented 8 years ago

@sadiq-mc any luck with this?

sadiq-mc commented 8 years ago

Sorry Andy, I couldn't able to test this. :(

andygup commented 8 years ago

Okay, I'm going to close this issue out. If you have new information that will help in troubleshooting then let us know.

sadiq-mc commented 8 years ago

Ok.. Will let you know the result once I test this case again.