You need to sign in to do that
Don't have an account?

VF mangling my JavaScript
I'm having an issue with what I believe is VF trying to interploate JavaScript. For example, given this JavaScript embedded in a VF page:
html += "<input type='checkbox' id='plVal" + val + "' value='" + field.picklistValues[val]+ "'/> " + field.picklistValues[val] + "<br/>";
This is output by VF:
html += "<input id="plVal" + val + "" type="checkbox" value="" + field.picklistValues[val]+ ""/> " + field.picklistValues[val] + "<br/>";
notice that VF has apparently identified the <input> which is inside a JS string. It swapped the order of the id and type attributes, and screwed some stuff up.
How can I prevent this? I tried the old trick surrrounding the JS code w/ html comments (<!-- -->), but VF outputs nothing but asterisks for the JS code.
Any idea how to prevent this, besides moving JS to an external file?
Which API version is your page using? We made a change to the VF compiler a few releases ago that should fix most if not all of these javascript issues, but it was pretty invasive and had to be versioned. If your page is using version 20.0 or higher I would expect this to go away.
All Answers
Which API version is your page using? We made a change to the VF compiler a few releases ago that should fix most if not all of these javascript issues, but it was pretty invasive and had to be versioned. If your page is using version 20.0 or higher I would expect this to go away.
I'll bet you can get around this simply by breaking up the "input" into two different strings. (e.g. "in" + "put").
Jill,
I bumped it from v19 to v21 and it solved the problem. Thanks for the tip!
Jeremy