evgenyneu / js-evaluator-for-android

A library for running JavaScript in Android apps.
MIT License
487 stars 84 forks source link

How to use js libraries like jQuery and MathJax? #19

Closed jianzhongli closed 9 years ago

jianzhongli commented 9 years ago

Hi! Great library, but I got one question. I saw

String jQuery = "/*! jQuery JavaScript Library v2.1.1 ...";
jsEvaluator.evaluate(jQuery + "; $.isNumeric(123)", new JsCallback() { ...

on the README.md file. But the above code is really confusing for me. Should I put the whole jQuery.js file into a Java String?

evgenyneu commented 9 years ago

Hi, you need to put jQuery into the Java string only if you intend to use jQuery. That was just an example of using a JavaScript library.

mohsin commented 9 years ago

Yes, but how? Would this include jquery or do I need to include the entire jquery library in as a minified string?

String jQuery = "<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js\"></script>”;
jsEvaluator.evaluate(jQuery + "; $.isNumeric(123)", new JsCallback() { ...
evgenyneu commented 9 years ago

@SaifurRahmanMohsin the latter, one needs to put the entire jQuery library into a string.