GithubHelp home page GithubHelp logo

dropmvc's Introduction

#dropmvc

Quick How To

A miniature Javascript framework for adding MVC-like flow to bits of a webpage. On a bright sunny day you:

  1. pick a container element as a view, a div around a comment for instance
  2. designate controls within it: a textarea for the comment and the submit button
  3. write some logic in the controller: validate input, submit the comment, give a visual response if all is ok
  4. glue controls to methods of the controller

The view will listen for events from its controls, and call methods on the controller when interesting things happen. Nothing fancy or difficult; just makes stuff a bit easier to organize. Like a cheap IKEA desk.

What's the point?

The point of it all is to split presentation and logic. You can write some control behaviour within each of your control objects, say, submitButton.disable() to disable the submit button when a comment has already been submitted. Then add more general presentation code to the view, like displaying some kind of confirmation message. The main logic will then go into the controller, where you can do your ajax, validation, processing, whatever it is your magical app does.

At the end of the day the controller doesn't have to directly touch any DOM elements: it can fire methods on its view and the view's controls, and if the appearance or the DOM elements behind the view or the control changes, it won't care: all of that DOM specific crap is encapsulated within the controls and views.

dropmvc's People

Contributors

dmkc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

suxianbaozi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.