1

我正在尝试为 a 的属性 ( backgroundColor)设置动画dijit/form/TextBox。当这不起作用时,我开始拔头发:

var node = dom.byId("myTextBox");
fx.animateProperty( {
    node : node, 
    duration : 750, 
    properties : {
        backgroundColor : {
            start : "yellow"
        }
    }
}).play();

但是,这有效:

var node = dom.byId("myTextBox");
fx.animateProperty( {
    node : node.parentNode.parentNode, // grandparent of "myTextBox" 
    duration : 750, 
    properties : {
        backgroundColor : {
            start : "yellow"
        }
    }
}).play();

这是它应该如何工作的吗?此页面上的示例不需要,但也没有使用 TextBox。

边问:有没有更直接相当于JQueryUI的highlight效果?这就是我想要的。

4

1 回答 1

1

改为获取对小部件对象的引用可能会更好dijit.byId("myTextBox")。然后,您可以参考myTextBox.domNodemyTextBox.focusNode根据您要突出显示的内容。我不确定您是否希望突出显示实际的文本输入区域或背景,但这个简单的 jsfiddle演示了两者。您的代码将更改为:

var textbox = dijit.byId("myTextBox");
fx.animateProperty( {
    node : textbox.focusNode // If you are trying to highlight the input background 
    duration : 750, 
    properties : {
        backgroundColor : {
            start : "yellow"
        }
    }
}).play();
于 2013-07-13T05:09:43.447 回答