Recently, I have been asked to modify the dynamically generated web page I worked on in order to have it generating TextAreas together with Inputs.
Having said that, I eventually had to change my JS code in order to store a TextView into this XML in a way similar to this:
myXML.myTextArea = <textarea rows="20" cols="10">
Afterwards my code would do this to render the textArea:
<%== myXML.myTextArea %>
Well.. pretty straightforward, right?
The problem is that this code would generate the following HTML:
<textArea cols="10" rows="10"/>
Unfortunately the HTML above doesn’t work since most of the browsers will interpret a self closing TextArea as an open tag (roughly). Apparently this is a bug at least in Chrome and Firefox and I’ve been able to reproduce it in IE9 as well.
This is how such a TextArea would look like:
The (all but orthodox) way I’ve managed to solve this is this (don’t laugh, please :
<%== myXML.myTextArea.toXMLString().replace("/>", "></textArea>") %>
So, whenever you have to use a textArea (either generated from an XML as in my case, or manually written) don’t forget:
TextArea can’t be a self closing tab (at least for now).