I'm dynamically constructing elements for recurring html.
I'm creating a display:table
, and all seems to be going well, but when I change the name
of an element before it's been $.append()
ed, it doesn't show up in Chrome "Elements" and cannot be later selected by jQuery; however, before $.append()
ing, the $.prop('name')
can be alert()
ed.
Should the dynamically constructed element be $.append()
ed before changing $.prop('name')
?
Code sample:
$.fn.appendSingleRecordInsert = function(paramaterObject) {
return this.each(function () {
var $appendDiv = $('<div/>')
...
$.each(paramaterObject.rows, function(rowKey, rowValue){
var $rowDiv = $('<div/>');
$.each(rowValue.columns, function(columnKey, columnValue){
var $columnDiv = $('<div/>');
if(typeof columnValue.name !== 'undefined'{
$columnDiv.prop('name', columnValue.name);
}
...
$rowDiv.append($columnDiv);
})
$appendDiv.append($rowDiv);
});
$(this)[paramaterObject.domInsertMethod]($appendDiv);
});