I have this long line of code that appends several elements with the jQuery .append()
method.
$('#file-names-js').append("<tr><td>"+fileName+"</td><td><input class='pull-right main-radio' onchange='Product.uncheck($(this));' name='product[images_attributes]["+formNum+"][main]' type='radio' "+checked+"></td><td><a class='close' onclick='Product.removeImage($(this), "+formNum+");' href='#'>×</a></td></tr>");
I tried separating the elements with commas and having them on separate lines (so it would be less hideous) by because they are nested within a <tr>
. So, when they were separated it would generate an empty <tr></tr>
before the other elements which caused issues.
TO CLARIFY: By better I mean more readable