5

I have created a windows 8 project using the phonegap 2.9.0 and then tried to use JQuery mobile library within it. But I get the following security exception. Any idea how to resolve this ?.

Exception was thrown at line 4, column 7009 in ms-appx://c6a291ce-903f-47ab-b167-  cb8378ffb051/www/libs/jquery.core/jquery-1.9.1.min.js

 0x800c001c - JavaScript runtime error: Unable to add dynamic content. A script attempted    to inject dynamic content, or elements previously modified dynamically, that might be unsafe.   For example, using the innerHTML property to add script or malformed HTML will generate this   exception. Use the toStaticHTML method to filter dynamic content, or explicitly create   elements and attributes with a method such as createElement.  For more information, see   http://go.microsoft.com/fwlink/?LinkID=247104.

 If there is a handler for this exception, the program may be safely continued.
msrameshp
  • 626
  • 2
  • 12
  • 33
  • Same question asked a while back: http://stackoverflow.com/questions/14471362/javascript-runtime-error-unable-to-add-dynamic-content – C.B. Aug 26 '13 at 23:53
  • No it's not the same thing. That's user defined javascript. This is coming from the JQuery Mobile library itself. – msrameshp Aug 27 '13 at 04:48
  • Anyone could you please help me ??. I am really stuck here :(. – msrameshp Aug 28 '13 at 04:50

1 Answers1

2

I have just run into the same problem. It appears that the grist of the matter is that the WinJS security model won't allow the JQuery dom manipulation when you create elements from strings e.g. using the .html() method.

See the below for more information: http://blogs.msdn.com/b/windowsappdev/archive/2013/04/01/windows-store-app-support-in-jquery-version-2-0.aspx

http://net.tutsplus.com/tutorials/javascript-ajax/building-windows-store-applications-with-jquery-2-0/

In summary the clever people have produced a fix to this in JQuery 2.0.

So I'll be looking at using JQuery 2.0 but will it work with JQuery Mobile? I haven't determined that yet so I'll probably look at fully building and attaching the dom elements rather than using the .html() method.

But please note that I have not tried any of these approaches yet so cannot vouch for their validity.

Shed Magnet
  • 211
  • 2
  • 7
  • Thanks for your input. I have already Solved the JQuery Issue by replacing JQuery 1.9.1 with JQuery 2.0. But I still get the same issue with JQuery Mobile both 1.3.2 and 1.4.0 alpha version. Do you have any ideas how I can solve those ?. – msrameshp Aug 31 '13 at 03:41
  • Late in the day but for what it's worth I abandoned using .html() and built my DOM components append by append. – Shed Magnet Nov 04 '14 at 14:51