Many of the sample code in the previous chapters also showed more or less how to use Ms-click to bind events. The ability to bind directly to a template is an event, which is also a big difference between a static template and a dynamic binding. Ms-click is not a simple onclick alias, it masks browser differences internally and is compatible with events that many browsers temporarily do not support.
In general, event bindings are implemented using ms-on-☆ bindings, but Avalon also provides a number of shortcuts that allow users to invoke those common events directly with Ms-eventname, as follows
Animationend, blur, change, input, click, DblClick, Focus, KeyDown, KeyPress, KeyUp, MouseDown, MouseEnter, MouseLeave, MO Usemove, Mouseout, mouseover, MouseUp, scan, scroll, submit
The format of the property value of the event binding, which must be the function name or the function name + parentheses (add parameters inside the parentheses).
Avalon's event bindings support multiple-throw event mechanisms (the same element can bind n homogeneous events, such as MS-CLICK=FN, Ms-click-1=fn2, MS-CLICK-2=FN3), to support the transfer of a parameter (the default first parameter is the event object, and if the first position is accounted for, we can use the $event to reference the event object elsewhere.) )
<! DOCTYPE html>
<! DOCTYPE html>
<! DOCTYPE html>Avalon has been repaired with Ms-mouseenter, Ms-mouseleave, and can be learned here with these two events. To Chrome30, all browsers natively support both events.
<! DOCTYPE html> Finally, the MouseWheel event was modified, the main problem is the emergence of Firefox, it is not willing to support MouseWheel, in Avalon is Dommousescroll or wheel to achieve simulation. We determine that the event object is scrolling up through the Wheeldelta property as a positive number.
<! DOCTYPE html>
Avalon also fixes the Input,animationend event, and you can bind these events directly with Avalon.bind, Avalon.fn.bind. However, the recommendations are handled using ms-on bindings.
Mini MVVM Framework Avalonjs Learning Tutorial 14, event binding