Very simple JS bidirectional data Binding framework (C): JS model Black Technology

Source: Internet
Author: User
Original intention

Before we have to update the model in the JS domain, we need this:

model.set(‘name‘‘sub‘);

This is really too earthy ...
We want to be like Angularjs, directly:

‘sub‘;

Then bong, the view will be updated! This kind of black technology must be excellent.

Goal
  1. Complete model update for black Tech
  2. Complete within 200 lines
Realize

This time the main reference to the Avalon "hijack" Setter,getter method, Link: Avalon Simplified version of Interpretation

It's difficult to read, although it's a simplified Avalon.
To organize the ideas, the main two major points:
1. VM Object –> Vmodel Object, Set,get method of hijacking VM's various properties
2. Scantag () –> traverse the DOM tree to find the keyword, go to Vmodel to find the evaluation function, register to the subscriber list

Which to go to vmodel this point is not very clear, these days must be clarified, their own mock a out

Very simple JS bidirectional data Binding framework (C): JS model Black Technology

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.