Inline jQuery for WebView won't work


#1

Hi guys,

I wanted to include jQuery in a WebView by putting the jQuery source code inline, but I get this error:

chromium: [INFO:library_loader_hooks.cc(104)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserStartupController( 2861): Initializing chromium process, singleProcess=true
chromium: [WARNING:resource_bundle.cc(304)] locale_file_path.empty()
chromium: [INFO:aw_browser_main_parts.cc(65)] Load from apk succesful, fd=50 off=46184 len=3037
chromium: [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.pak from, fd:51 off:229484 len:1089587
chromium: [WARNING:data_reduction_proxy_settings.cc(331)] SPDY proxy OFF at startup
chromium: [INFO:CONSOLE(624)] “Uncaught SyntaxError: Unexpected token ?”, source: file:///data/data/org.nativescript.groceries/files/app/ (624)
chromium: [INFO:CONSOLE(10283)] “Uncaught TypeError: Cannot read property ‘fn’ of undefined”, source: file:///data/data/org.nativescript.groceries/files/app/ (10283)
chromium: [INFO:CONSOLE(10331)] “Uncaught ReferenceError: $ is not defined”, source: file:///data/data/org.nativescript.groceries/files/app/ (10331)

My problem is with the line that say Unexpected token ?, It pops up when I tried putting jQuery minified or uncompressed. If I replace inline jQuery with a cdn, it works. I copy pasted the code from the cdn to my code and it still doesn’t work. I think the issue is with the parsing, but I’m not sure.

Also, I need it to work offline, so using the CDN isn’t really an option as far as I know.

Please help me fix it.

My code is at: http://pastebin.com/EZtZJPK9

Thank you


#2

I guess I don’t understand why you are using jQuery in an Angular and / or NativeScript app. Are you sure this is the architecture you want to create your word cloud? What about using a WrapLayout with Labels, or some such?


#3

Labels or other elements dont have rotate and similar things so its almost impossible to do but no need for jquery but depends


#4

The problem was apparently the backslashes. Since jQuery included regex in its source code, the backslashes were being parsed in the HTML string. The fix was to replace all backslashes with a double backslash.