1

i am trying to build a mobile app, but i need some jQuery functions to make it function. at first i thought nothing was wrong since i am debugging it using ionic serve on firefox and everything seems to function. all interface runs smooth and jquery commands executing properly. but when i compiled the app and installed it on my android device. the jquery functions seems to not respond.

i embedded a CDN for the jQuery

<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"> </script>

i hope somebody can help me out here.

TheBloodShed
  • 11
  • 1
  • 2
  • if you include the jquery file in your project does it still gives the same error? – Miguel Aug 20 '15 at 11:27
  • 2
    You shouldn't use jQuery with Ionic/Angular cause you shouldn't manipulate the DOM with jQuery but use angular directives instead. More info [here](http://stackoverflow.com/a/15012542/219406). – LeftyX Aug 20 '15 at 11:52
  • @Miguel, yes is still does. – TheBloodShed Aug 20 '15 at 12:00
  • @LeftyX, so in short AngularJS and jQuery doesn't mix together ? – TheBloodShed Aug 20 '15 at 12:01
  • 1
    @TheBloodShed: Yes. I would suggest not using jQuery and go for angular directives. Ionic is build on top of AngularJs and defines directives and modules. You can find [angular modules](http://ngmodules.org/) for pretty much everything. – LeftyX Aug 20 '15 at 12:05

1 Answers1

2

Since you have used a CDN for jQuery the application makes a http request to retrieve the js file when its run. This happens in background when you run the application on the browser with ionic serve. But when you run it on a mobile device it needs to have special permissions configured to make the required http requests.

White listing the domain using the cordova-plugin-whitelist will solve the issue.

truchiranga
  • 469
  • 5
  • 10