mithril-vndb/docs
pelonpelon 7ce8429bf4 Update components.md -- "Classic MVC" example
@ArthurClemens pointed out in this gitter comment:
https://gitter.im/lhorie/mithril.js?at=55664ba1d21e5ed02ff06e54
that the Classic MVC example is broken:
https://lhorie.github.io/mithril/components.html#classic-mvc

I wanted to show a working jsfiddle with these changes applied, but I couldn't figure out how to get a POST request working. I do, however, have a jsbin that is working, although there are significant changes in the code to allow for GET and POST.
http://jsbin.com/cokesu/2/edit?js,output

A redraw is called for every character entered in the jsbin but AFAICT, not in this PR. I don't know why. It's as though `oninput` is really `onchange`. It's possible to limit the redraw to once when the "save" button is clicked, but this requires a change in logic:

var ContactForm = {
    controller: function(args) {
        this.contact = m.prop(new Contact())
        this.save = function(contact) {
           Observable.trigger("saveContact", {contact: contact})
        }
    },
    view: function(ctrl, args) {
        var contact = ctrl.contact()

        return m("form", [
            m("label", "Name"),
            m("input[name=name]"),

            m("label", "Email"),
            m("input[name=email]"),

            m("button[type=button]", {onclick: function(){
              contact = {
                name: m.prop(this.parentNode.elements.name.value),
                email: m.prop(this.parentNode.elements.email.value)
              }
              ctrl.save(contact)
            
            }}, "Save")
        ])
    }
}
2015-05-28 03:47:40 -05:00
..
layout fix typo 2015-05-03 19:31:05 -04:00
auto-redrawing.md improve docs about redrawing 2015-04-20 22:16:27 -04:00
benchmarks.md add section about todomvc benchmark 2014-12-31 16:39:17 -05:00
change-log.md add migration note 2015-04-30 21:52:38 -04:00
community.md change order in community page 2015-03-24 23:56:22 -04:00
comparison.md update size 2015-04-22 21:18:55 -04:00
components.md Update components.md -- "Classic MVC" example 2015-05-28 03:47:40 -05:00
getting-started.md corrected typo 2015-05-07 10:37:34 +05:00
how-to-read-signatures.md improve docs 2014-09-14 00:52:11 -04:00
installation.md fix link 2015-05-01 09:30:18 -04:00
integration.md rework api 2015-04-09 22:44:45 -04:00
mithril.component.md Fix conversion in component stateless example 2015-05-08 20:16:12 -07:00
mithril.computation.md improve docs about redrawing 2015-04-20 22:16:27 -04:00
mithril.deferred.md Small change to example code 2015-02-01 00:59:46 -07:00
mithril.deps.md fix formatting in docs 2014-09-27 21:01:00 -04:00
mithril.md remove outdated warning 2015-04-27 22:02:12 -04:00
mithril.mount.md Clarification on m.mount() signature 2015-05-07 08:51:36 -05:00
mithril.prop.md rework api 2015-04-09 22:44:45 -04:00
mithril.redraw.md improve docs 2015-04-21 08:20:00 -04:00
mithril.render.md add missing return 2015-03-30 10:55:34 -04:00
mithril.request.md improve docs 2015-04-24 08:22:42 -04:00
mithril.route.md Update mithril.route.md 2015-05-02 22:55:10 +09:00
mithril.sync.md fixing links 2014-08-12 18:00:54 -04:00
mithril.trust.md Copy edit docs 2014-05-26 23:51:16 -05:00
mithril.withAttr.md changes in the docs: rename modules to components, change idiomatic controller and view usage 2015-04-06 22:41:38 -04:00
optimizing-performance.md #307 fix compiler bugs 2014-10-13 21:22:38 -04:00
practices.md remove references to m.module 2015-04-22 21:18:41 -04:00
roadmap.md initial release 2014-03-16 22:07:53 -04:00
routing.md remove references to m.module 2015-04-22 21:18:41 -04:00
tools.md tools.md: explicitly say IE8 needs polyfills 2015-02-23 00:39:05 -05:00
web-services.md changes in the docs: rename modules to components, change idiomatic controller and view usage 2015-04-06 22:41:38 -04:00