Clone a dojo floating pane
I am trying to clone the floating pane object as follows.
var pFloatingPane = new dojox.layout.FloatingPane({
title: "A floating pane",
resizable: true,
dockable: true,
开发者_如何学JAVA style: "position:absolute;top:0;left:0;width:136px !important;height:100px;visibility:visible;",
id: "pFloatingPane"
}).placeAt(dojo.byId("gridContainer"));
var secondPane = dojo.clone(pFloatingPane);
but it gives the following error when I debug with chrome javscript debugging tool.
Uncaught TypeError: Cannot read property 'id' of undefined
But it works fine with following one eventhough i dont give an id at initializing point.
var topContentPane1 = new dijit.layout.ContentPane(
{
region: "top",
splitter: true,
minSize : 10,
maxSize : 84
},
document.createElement("div")
);
var secondOne = dojo.clone(topContentPane1);
can some one pls tell me how to resolve this problem. thanks in advance
I'm not sure cloning Widgets is supported behaviour 1. They all have to have an unique ID (and one will be generated if you don't pass one yourself) and I could see that causing trouble. There are also no guarantees that widgets are free of cyclic references and the events like onClick, etc are likely to get messed up.
Is there any special reason you want clone that prevents you from just using a simple solution like encapsulating the widget creation in a function?
function make_pane(){
new dijit.layout.ContentPane({
//...
});
}
var first = make_pane();
var second = make_pane();
精彩评论