以下代码只是尝试克隆一行并重置克隆的id:
rowTemplate = j('#component .form-list:first-child').clone();
var newRow = dojo.clone(rowTemplate);
dojo.attr(newRow, 'id', newRowId);
然而,从萤火虫第三行给我
TypeError: node.setAttribute is not a function (dojo.js)
从调试我可以看到newRow是一个Object(对象[#row.class]),所以问题是:如何(或是否有必要)将Javascript对象转换为Dom以使其可用于dom函数?
答案 0 :(得分:2)
如果要将jQuery对象与dojo方法一起使用,则必须将jQuery对象转换为dom元素集合。这可以使用.get()
rowTemplate = j('#component .form-list:first-child').clone();
var newRow = dojo.clone(rowTemplate.get(0));
dojo.attr(newRow, 'id', newRowId);
免责声明:我不熟悉道场方法。