相关疑难解决方法(0)

YUI 3以编程方式触发更改事件

我想知道如何以编程方式使用YUI3触发更改事件 - 我向一个选择框节点添加了一个更改侦听器:

Y.get('#mynode').on('change', function(e) {
 Alert(“changed me”);
});
Run Code Online (Sandbox Code Playgroud)

脚本中的其他地方想要触发该事件.当然,当用户更改浏览器中的选择框值时,它可以工作.但我已经尝试了很多方法来以编程方式启动它,但没有一种方法可行.包含:

// All below give this error: T[X] is not a function (referring to what's called in .invoke(), // in the minified javascript
Y.get('#mynode').invoke('onchange');
Y.get('#mynode').invoke('change');
Y.get('#mynode').invoke('on','change');
Y.get('#mynode').invoke("on('change')");


/* Tried using .fire() which I found here: 
* http://developer.yahoo.com/yui/3/api/EventTarget.html#method_fire
* Nothing happens
*/

Y.get('#mynode').fire('change'); 

/* Looking around the APIs some more, I found node-event-simulate.js: 
 * http://developer.yahoo.com/yui/3/api/node-event-simulate.js.html, 
 * which by its name would seem to have what I want. I tried:
 * Error: simulate(): …
Run Code Online (Sandbox Code Playgroud)

events onchange yui3

16
推荐指数
2
解决办法
1万
查看次数

标签 统计

events ×1

onchange ×1

yui3 ×1