jQuery多点击处理程序..如何确保点火顺序?

puf*_*pio 1 jquery live event-handling

我有2个点击处理程序绑定到一个元素,如下所示:

在包含我绑定的控件的文件中,我有第一个处理程序,它执行特定于该控件的一些功能

$("#mycontrol").live("click", function() { alert("foo"); });
Run Code Online (Sandbox Code Playgroud)

在使用该控件的主页面中,我有另一个处理程序绑定到该元素以获取特定于页面的功能

$("#mycontrol").live("click", function() { alert("bar"); });
Run Code Online (Sandbox Code Playgroud)

我使用'live'因为AJAX调用一直在改变控件,所以处理程序将被重新注册.但是我需要一种方法让"foo"在"bar"之前一直发生......任何建议?

Yuv*_*dam 5

怎么样:

$("#mycontrol").live("click", doFooBar);

function doFooBar() {
    alert("foo");
    alert("bar");
}
Run Code Online (Sandbox Code Playgroud)