Mini MVVM Framework Avalonjs Learning Tutorial 14, event bindings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.