I have the following jQuery (admittedly messy at the moment) which appends a new row to a table. However, it's not inserting the <cfinput> field. In fact, somehow coldfusion is reading that tag inside the javascript block because it throws a CF error.
Context validation error for tag cfinput.The tag must be nested inside a cfform tag
If I change it to a normal <input>, then the problems go away and the field is inserted.
I need the <cfinput> to make use of ColdFusion's native date picker. Regardless, I'm curious why this is happening.
$(".aAddLine").click(function(e){
var clickedID = $(this).attr("id");
var lineNo = parseInt(clickedID.split("_")[1])
var newLineNo = parseInt(lineNo+1)
var x = "";
$('#tdPlus_' + lineNo).html("");
x += '<tr>';
x += '<td width="50" class="tdPlus' + newLineNo + '"><a class="aAddLine" id="aAddLine_' + newLineNo + '" href="##">+ Line</a></td>';
x += '<td valign="top">Date</td>';
/*issue with the <cfinput> on the line below */
x += '<td><cfinput class="dt validate" type="datefield" name="startDate" id="startDate_' + newLineNo + '" validate="eurodate" mask="dd/mm/yyyy" /> <span class="res" id="resStartDate_' + newLineNo + '"> <span class="hint"></span></span></td>';
x += '<td style="width:10px"> </td>';
x += '<td>Time</td>'
x += '<td><input class="validate" type="datefield" name="startTime_' + newLineNo + '" id="startTime_' + newLineNo + '" style="width:35px;"/> <span class="res" id="resStartTime_' + newLineNo + '"></span> to <input class="validate" type="datefield" name="endTime_' + newLineNo + '" id="endTime_' + newLineNo + '" style="width:35px;"/> <span class="res" id="resEndTime_' + newLineNo + '""></span></td>'
x += '</tr>'
$('#tblItem > tbody:last').append(x);
e.preventDefault();
e.stopPropagation();
});
Any help appreciated!