Mpvc Part 1 in front-end design mode

Source: Internet
Author: User

Mpvc is short for model partial-View Controller ).

Recently I saw the mvvm mode and situ zhengmeiThere are some new ideas about the aveon framework. Mvvm deficiencies are considered as follows:

    • All templates need to be placed on the front end (maybe the back end needs another copy ?)
    • Modeling is only required for display purposes. Even fields not involved in logical processing need to be modeled, which is quite troublesome.
    • Different pages require different VMS, resulting in high maintenance costs.
    • For multi-page applications, you still need to writeCodeTo controlProgramWork Logic

The biggest beauty is that the data model is automatically bound to the view display.

Let's leave the MVC pattern aside, and start with the following structure and workflow:

    • For an unspecified web application, a page should be composed of several different blocks. Different blocks are divided by functional areas.
    • Different pages are composed of different functional area blocks.
    • Webpage applications use Ajax technology to update only a part of the page content in order to pursue user experience. This process can be abstracted as the view refresh, add, and delete of functional area blocks.

This code is usually written in simple application development:

 
$. Get ('/action_url ',Function(Result) {$ ('# Result_panel'). Innerhtml (result );});

Repeat this process when updating the view, and other problems may occur:

    • $ ('# Result_panel') strongly binds the code logic to the DOM element. Because the uniqueness of the ID limits the code block, it can only be used in singleton mode.
    • $ ('. Action-hook-class ') indicates that the global space is contaminated and unnecessary selector scanning is required on pages that do not need to start this feature, to enable or disable this feature, additional control switch logic is required.

Modular code writing can avoid these problems: $ ('. Result-panel', contextscope) or $ ('. Action-hook-class', contextscope) is much more friendly.

 

 

 

 

 

 

 

 

 

 

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.