Javascript 用于动态内容的Dojo moveable
我正在使用dojo domConstruct创建动态html元素,如下所示Javascript 用于动态内容的Dojo moveable,javascript,dojo,Javascript,Dojo,我正在使用dojo domConstruct创建动态html元素,如下所示 //ID, all style parameters are available in function var vertex = domConstruct.create("div", { id: node.ID, "class": type, style: { left: node.position.x +'px', top: node.position.y +'px', bord
//ID, all style parameters are available in function
var vertex = domConstruct.create("div", {
id: node.ID,
"class": type,
style: {
left: node.position.x +'px',
top: node.position.y +'px',
border: colorBorder.border,
'box-shadow': colorBorder.boxShadow,
backgroundColor: colorBorder.backgroundColor,
position:'absolute'
},
innerHTML: nodeName
}, "statemachine-demo");
//using dojo Moveable
var moveableHandle = new Moveable(vertex);
console.log("priting moveable object before passing to adapter",moveableObject);
我必须使此元素可移动,因此我使用dojo moveable,如下所示
//ID, all style parameters are available in function
var vertex = domConstruct.create("div", {
id: node.ID,
"class": type,
style: {
left: node.position.x +'px',
top: node.position.y +'px',
border: colorBorder.border,
'box-shadow': colorBorder.boxShadow,
backgroundColor: colorBorder.backgroundColor,
position:'absolute'
},
innerHTML: nodeName
}, "statemachine-demo");
//using dojo Moveable
var moveableHandle = new Moveable(vertex);
console.log("priting moveable object before passing to adapter",moveableObject);
当我运行它时,日志显示以下行
在传递到适配器之前撬动可移动对象
对象
延迟:0
事件:null
句柄:null
移动器:函数(){
节点:空
onMove:function(){
onMoveStart:函数(){
onMoveStop:函数(){
跳过:未定义
__原型:对象
我不明白为什么句柄和节点保持空?理想情况下应该有对moveable元素的引用
是因为在应用Moveable时Dom中不存在元素吗?我认为您使用的变量有问题。我使用了绝对值,而不是您在程序中使用的node、type、colorborder等变量,对我来说效果很好。请检查这些值 还要确保“statemachine demo”是正确的id名称,或者使用domConstruct.place方法 您可以检查示例的工作版本-
我使用setTimeout解决了这个问题,它延迟了对可移动对象的创建
//using lang.hitch for passing the context
setTimeout(lang.hitch(this,new function(){
//vertex from the context
var moveableHandle = new Moveable(vertex);
console.log("priting moveable object before passing to adapter",moveableObject);
//do stuff with moveable .....
}),1000);