2013-07-24 74 views
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

感谢...新道场..

编辑: 好像它进入inlineeditbox。 js和打破此行:this.displayNode.setAttribute("role", "button");

+0

是新的Textarea();道场的事情或错误? – dandavis

+0

你好..这是一个道场的事情 – BigBug

+0

我的不好。我们在这里看到很多垃圾,上次我检查了它,dojo使用了命名空间。我想即时通讯不是最新的五年的javascript怪胎,永远不会去任何地方... – dandavis

回答

0

尝试:

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(); 
}); 
+0

嗨,我找到了解决方案。它有ID“ieb”...而是我希望重新与节点“ieb”。这个伎俩。不管怎么说,还是要谢谢你 :) – BigBug