Bindaseventlistener is a method of the function class in MT, which is to create a closure and automatically pass in an event instance, which is usually used to do the incident listener
Its return value is: A function closure that binds this and the prefetch parameter event (or window.event, different depending on the browser).
Note that the event is just an ordinary event instance, not an instance of the event class in MT, so it does not have properties in the event class, such as event.page.x, and so on.
Bindasevent is a prototype method that the event class in Mt adds to the Functionle class. The effect is that an MooTools event class instance is automatically passed in to the target function.
Here is an example of the difference between the two:
1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2. 3. 4. <title>无标题页</title>
5. <script type="text/javascript" src="mt.js"></script>
6. 7.<body>
8.
9.<a id="demo" style="width:100px;height:50px;border:1px solid red;display:block" href="http://www.google.cn"></a>
10.
11.<script type="text/javascript">
12.var myElement = $('demo');
13.14.function myFunction(event){
15. //var event = new Event(event);
16. //event.stop();
17.
18. alert(event.client.x);
19.};
20.myElement.onclick = myFunction.bindAsEventListener(myElement); //报错
21.myElement.addEvent('click', myFunction.bindWithEvent(myElement)); //正常
22.</script>
23.</body>
24.