就地编辑问题

时间:2013-07-24 21:25:58

标签: javascript html dojo

我想为某些东西创建就地编辑,我想首先创建一个可以编辑文本的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

提前感谢...新道场..

修改 的 看起来它正在进入inlineeditbox.js并打破这一行:this.displayNode.setAttribute("role", "button");

1 个答案:

答案 0 :(得分: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();
 });