Merge branch 'next' of https://github.com/lhorie/mithril.js into next
This commit is contained in:
commit
e7ef34ef4e
8 changed files with 16 additions and 16 deletions
|
|
@ -68,7 +68,7 @@ app.view = function(ctrl) {
|
|||
|
||||
|
||||
//initialize
|
||||
m.module(document.getElementById("example"), app);
|
||||
m.mount(document.getElementById("example"), app);
|
||||
```
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ Some of the older frameworks among the popular ones (out-of-the-box jQuery and B
|
|||
|
||||
This can get noticeably bulky when you look at thing like collections: you often need to implement insertion code and deletion code, in addition to a "draw everything" routine for performance. And this is for every list that needs to be displayed in some way.
|
||||
|
||||
Mithril's view layer paradigm is designed be **declarative**, much like HTML, such that the same code implicitly does everything it needs to. As it turns out, this design decision is actually a compromise: it offers the benefit of decreased application code complexity at the cost of some performance loss. However, as the performance tests in the homepage show, this does not necessarily hurt Mithril in a meaningful way.
|
||||
Mithril's view layer paradigm is designed to be **declarative**, much like HTML, such that the same code implicitly does everything it needs to. As it turns out, this design decision is actually a compromise: it offers the benefit of decreased application code complexity at the cost of some performance loss. However, as the performance tests in the homepage show, this does not necessarily hurt Mithril in a meaningful way.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ m.render(document.body, [
|
|||
m("a", {href: link.url}, link.title)
|
||||
);
|
||||
})
|
||||
])
|
||||
)
|
||||
]);
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ var User = {
|
|||
this.name = m.prop(name);
|
||||
},
|
||||
controller: function() {
|
||||
this.user = new user.model("John Doe");
|
||||
this.user = new User.model("John Doe");
|
||||
},
|
||||
view: function(controller) {
|
||||
m.render("body", [
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ demo.controller = function() {
|
|||
demo.view = function(ctrl) {
|
||||
//This view gets rendered before the request above completes
|
||||
//Calling .map doesn't throw an error because we defined the initial value to be an empty array, instead of undefined
|
||||
return ctrl.users().map(function() {
|
||||
return ctrl.users().map(function(user) {
|
||||
return m("div", user.name)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
//drag and drop micro-library
|
||||
function dragdrop(element, options) {
|
||||
options = options || {}
|
||||
|
||||
|
||||
element.addEventListener("dragover", activate)
|
||||
element.addEventListener("dragleave", deactivate)
|
||||
element.addEventListener("dragend", deactivate)
|
||||
|
|
@ -35,7 +35,7 @@ Uploader.upload = function(files) {
|
|||
for (var i = 0; i < files.length; i++) {
|
||||
formData.append("file" + i, files[i])
|
||||
}
|
||||
|
||||
|
||||
return m.request({
|
||||
method: "POST",
|
||||
url: "http://localhost/api/files",
|
||||
|
|
@ -85,10 +85,10 @@ demo.view = function(ctrl) {
|
|||
]
|
||||
}
|
||||
|
||||
m.module(document.body, demo)
|
||||
m.mount(document.body, demo)
|
||||
|
||||
//submodule helper
|
||||
function submodule(module, args) {
|
||||
return module.view.bind(this, new module.controller(args))
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -66,5 +66,5 @@ todo.view = function() {
|
|||
};
|
||||
|
||||
//initialize the application
|
||||
m.module(document, {controller: todo.controller, view: todo.view});
|
||||
</script>
|
||||
m.mount(document, {controller: todo.controller, view: todo.view});
|
||||
</script>
|
||||
|
|
|
|||
10
mvc.html
10
mvc.html
|
|
@ -62,14 +62,14 @@ var ContactForm = {
|
|||
},
|
||||
view: function(ctrl) {
|
||||
var contact = ctrl.contact()
|
||||
|
||||
|
||||
return m("form", [
|
||||
m("label", "Name"),
|
||||
m("input", {oninput: m.withAttr("value", contact.name), value: contact.name()}),
|
||||
|
||||
|
||||
m("label", "Email"),
|
||||
m("input", {oninput: m.withAttr("value", contact.email), value: contact.email()}),
|
||||
|
||||
|
||||
m("button[type=button]", {onclick: ctrl.createContact}, "Create")
|
||||
])
|
||||
}
|
||||
|
|
@ -92,5 +92,5 @@ var ContactList = {
|
|||
}
|
||||
}
|
||||
|
||||
m.module(document.body, ContactsWidget)
|
||||
</script>
|
||||
m.mount(document.body, ContactsWidget)
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue