0

我想为某些东西创建就地编辑,我想从创建一个具有可编辑文本的 div 开始......但我面临一个问题:

Uncaught TypeError: Cannot call method 'setAttribute' of null 

这是我的代码:

var node = dojo.createElement("div");
node.setAttribute("id", "ieb");


var area = new Textarea(); 

var newContent = document.createTextNode("When you click on this div you'll be able to edit it (in plain text).The editor's size will initially match the size of the (original) text, but will expand/contract as you type.");

node.appendChild(newContent);
var eb = new InlineEditBox({
    editor: area,
    autoSave: false
}, "ieb");

我在这里做错了什么?或者我错过了什么?

我试图长期关注本教程: http ://dojotoolkit.org/reference-guide/1.9/dijit/InlineEditBox.html

在此先感谢... dojo 的新手..

编辑: 似乎它正在进入 inlineeditbox.js 并打破这一行:this.displayNode.setAttribute("role", "button");

4

1 回答 1

1

尝试:

require(["dojo", "dijit/InlineEditBox", "dijit/form/Textarea"], function (dojo, Textarea, InlineEditBox) {
var node = dojo.create("div", {
    id: "ieb",
    innerHTML: "When you click on this div you'll be able to edit it (in plain text).The editor's size will initially match the size of the (original) text, but will expand/contract as you ty"
}, dojo.body());


var eb = new InlineEditBox({
    editor: Textarea,
    autoSave: false
}, "ieb");

eb.startup();
 });
于 2013-07-24T22:39:55.403 回答