KnockoutJS’s Containerless Control Flow Syntax and Issues on 3G Networks

KnockoutJS’s Containerless Control Flow Syntax and Issues on 3G Networks

After having extensively worked on a new app, I have finally come-around to the point at which I tested it on my mobile device.

I then realised that the containerless control flow syntax did not work. After remotely debugging it through the Android SDK, I checked the source of the app on my mobile: all HTML comments were removed by my UK mobile network so as to reduce their bandwidth.

Of course, this meant crucial components of my app were simply not working any more.

However, the fix was easy enough. It turns-out, the network does not remove HTML comments within script-tags.

All you need to do is move your app’s HTML-markup into a template, such as:

1
<script id="app-template" type="text/html">[...]</script>

Then, you can load the template from within your app’s body like this:

1
<div data-bind="template: { name: 'app-template' }"></div>

And volá: your app now works!

No comments

Leave a reply

Your email is never published nor shared. Required fields are marked *

Security Question * Time limit is exhausted. Please reload CAPTCHA.