Windows 8: Using jQuery in your Windows Store app

Right, so I thought it would be great to write a HTML5 app in windows 8 since it’s supported and everything. The one thing I refuse to skip though is jQuery. So, I added jQuery 1.9.1 to my app, referenced it in my html-file and ran the app. The following popup showed up:

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.
The error I received

I searched the web and I found that the only solution that seems safe at the time of writing is to use a “fixed” version for Windows 8, supplied by a company called AppendTo. The files can be downloaded here:

Currently the latest jQuery release is 1.9.1 and the AppendTo conversion is 1.8.2 but it’s close enough and it works for me.

According to a couple of videos floating around and some articles on the subject the jQuery 2.0 release will have full support for Windows 8 so that should be great. But until then the AppendTo solution seems to be the best one out there.

Leave a Reply