Mini MVVM Framework Avalonjs Learning Tutorial 7, data caching

Source: Internet
Author: User

Many of the functions of jquery can be handled through the binding properties of Avalon, such as the click Method corresponding to the Ms-click,css method corresponding to the Ms-css,toggle method corresponding to the ms-visible, its data caching function Avalon also moved over. But unlike jquery, Avalon is the data-☆ attribute that saves data directly to the element node's HTML5. When you restore data from the Data-☆ property, it will simply convert the data back to you.

In Ms-data bindings, consider that if you convert an object to a string and then restore it, you lose the function or something, so they are saved directly above the element.

<! DOCTYPE html>

This is a very simple binding, nothing to say, just remember that objects and arrays are stored directly on the element node on the line. The following is its source code:

"Data": Function (val, elem, data) {    var key = "data-" + Data.param    if (val && typeof val = = = "Object") {
   elem[key] = val    } else {        elem.setattribute (key, String (val))    }},

Mini MVVM Framework Avalonjs Learning Tutorial 7, data caching

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.