在mootools中:在元素上的所有事件完成后调用函数

时间:2010-03-01 09:52:59

标签: mootools

我有这个元素,应用了各种变化事件 如何在mootools中发生所有更改事件后触发我自己的功能

示例场景是下拉列表

$('ddl')。addEvent('change',function(){ //这里有一些ajax调用,我无法影响 //因为页面是以这种方式生成的 });

我现在想在更改事件完成后立即调用我的函数但是添加另一个更改事件将不会,因为我相信事件是执行异步

1 个答案:

答案 0 :(得分:0)

通过你引用的ajax的onComplete传递一个回调函数。

例如:

$("ddl").addEvents({
    change: function() {
        new Request({
           method: "get",
           url: "somefile.php",
           onComplete: function() {
               // run your next stuff from within here, referencing 
               // this.response.text or whatevever and call up another function.
           }
        }).send("action=checkuser&id="+this.get("value").trim());
    }
});

还有Chain类 - http://mootools.net/docs/core/Class/Class.Extras#Chain但是当你有异步的东西时,你真的需要请求上的onComplete。

相关问题