2013-07-24 108 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