Skip to content

TodoMVC in Mithril v2 or Where did controller() view(ctrl) go? #18

Closed
@space88man

Description

@space88man

Requesting for TodoMVC guide for v2. Currently, the example uses

var app = app || {};
app.controller = function () {

and

app.view = (function () {
	var focused = false;

	return function (ctrl) {

		return [
			m('header.header', [
				m('h1', 'todos'), m('input.new-todo[placeholder="What needs to be done?"]', {

However this pattern isn't documented (last was in v0.2.5). The Simple application tutorial uses either
view: function(){...} or view: function(vnode){...}.

The view receives accepted or 'completed from the URL capture '/:filter' as the filter property on the ctrl argument populated by controller().

In modern mithril (>=v2)/Simple application tutorial it comes in by vnode.attrs.filter? The TodoMVC example still works on v2, how did the view function know it was receiving (old-style) ctrl or vnode?

in view: function(vnode){} I would expect the URL capture /:filter (filter = "active" or "completed") to appear as vnode.attrs.filter. However the received argument ctrl does not seem to be polymorphic (it does not have an attrs property).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions