function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jbroquistjbroquist 

Using Visualforce and Knockout.js without a container element

I recently had issues with using Knockouts HTML comment tagging system with Visualforce. After searching around I found a good workaround which I detail in my blog post.

 

I thought I would share this workaround with everyone so you don't bang your head on your desk for hours trying to get Knockout to work.

 

Let me know what you think!

sfdcfoxsfdcfox
That's not a bad little component. Several of us here at the forums have all tackled this, and there's certainly other solutions out there, too, but keep in mind that salesforce is actively working to make their pages MORE secure, including anti-injection techniques, so we really do need that Idea implemented before then.
bob_buzzardbob_buzzard

I had a bit of an exchange with some of the SFDC guys when Winter 12 came out, as they'd included some stuff to help with knockout.js but not this.  There seems to be a real aversion to allowing HTML comments through in Visualforce, but I couldn't find out why that was.  The weird bit for me is sending them through but starred out. Either leave them alone or get rid of them completely, otherwise its just a waste of bandwidth!

sfdcfoxsfdcfox

It's an odd thing, certainly. Though, "starring them out" actually compresses them well, so the bandwidth isn't a huge deal, but I agree that they should just as well be left alone; there's plenty of legitimate reasons to have comments in code, and developers that leave in "harmful" comments shouldn't have their job long anyways.