update docs

This commit is contained in:
Leo Horie 2016-06-20 09:22:00 -04:00
parent b9ce90765d
commit ce0c30a235
11 changed files with 849 additions and 236 deletions

View file

@ -18,7 +18,7 @@ In `v0.2.x` mithril provided a single lifecycle method, `config`. `v1.x` provide
### `v0.2.x`
```js
```javascript
m("div", {
config : function(element, isInitialized) {
// runs on each redraw
@ -31,20 +31,20 @@ m("div", {
More documentation on these new methods is available in [lifecycle-methods.md](lifecycle-methods.md).
```js
```javascript
m("div", {
// Called before the DOM node is created
oninit : function(vnode) { ... },
oninit : function(vnode) { /*...*/ },
// Called after the DOM node is created
oncreate : function(vnode) { ... },
oncreate : function(vnode) { /*...*/ },
// Called before the node is updated, return false to cancel
onbeforeupdate : function(vnode, old) { ... },
onbeforeupdate : function(vnode, old) { /*...*/ },
// Called after the node is updated
onupdate : function(vnode) { ... },
onupdate : function(vnode) { /*...*/ },
// Called before the node is removed, call done() when ready for the node to be removed from the DOM
onbeforeremove : function(vnode, done) { ... },
onbeforeremove : function(vnode, done) { /*...*/ },
// Called before the node is removed, but after onbeforeremove calls done()
onremove : function(vnode) { ... }
onremove : function(vnode) { /*...*/ }
});
```
@ -56,7 +56,7 @@ If available the DOM-Element of the vnode can be accessed at `vnode.dom`.
### `v0.2.x`
```js
```javascript
m("div", {
onclick : function(e) {
m.redraw.strategy("none");
@ -66,7 +66,7 @@ m("div", {
### `v1.x`
```js
```javascript
m("div", {
onclick : function(e) {
e.redraw = false;
@ -80,7 +80,7 @@ In `v1.x` there is no more `controller` property in components, use `oninit` ins
### `v0.2.x`
```js
```javascript
m.mount(document.body, {
controller : function() {
var ctrl = this;
@ -96,7 +96,7 @@ m.mount(document.body, {
### `v1.x`
```js
```javascript
m.mount(document.body, {
oninit : function(vnode) {
vnode.state.fooga = 1;
@ -130,7 +130,7 @@ Arguments to a component in `v1.x` must be an object, simple values like `String
### `v0.2.x`
```js
```javascript
var component = {
controller : function(options) {
// options.fooga === 1
@ -146,7 +146,7 @@ m("div", m.component(component, { fooga : 1 }));
### `v1.x`
```js
```javascript
var component = {
oninit : function(vnode) {
// vnode.attrs.fooga === 1
@ -166,14 +166,14 @@ In `v0.2.x` you could pass components as the second argument of `m()` w/o any wr
### `v0.2.x`
```js
m("div", <component>);
```javascript
m("div", component);
```
### `v1.x`
```js
m("div", m(<component>));
```javascript
m("div", m(component));
```
## `m.route()` and anchor tags
@ -182,7 +182,7 @@ Handling clicks on anchor tags via the mithril router is similar to `v0.2.x` but
### `v0.2.x`
```js
```javascript
// When clicked this link will load the "/path" route instead of navigating
m("a", {
href : "/path",
@ -192,7 +192,7 @@ m("a", {
### `v1.x`
```js
```javascript
// When clicked this link will load the "/path" route instead of navigating
m("a", {
href : "/path",
@ -206,7 +206,7 @@ In `v0.2.x` all interaction w/ the current route happened via `m.route()`. In `v
### `v0.2.x`
```js
```javascript
// Getting the current route
m.route()
@ -216,7 +216,7 @@ m.route("/other/route");
### `v1.x`
```js
```javascript
// Getting the current route
m.route.getPath();
@ -230,7 +230,7 @@ In `v0.2.x` reading route params was all handled through the `m.route.param()` m
### `v0.2.x`
```js
```javascript
m.route(document.body, "/booga", {
"/:attr" : {
view : function() {
@ -242,7 +242,7 @@ m.route(document.body, "/booga", {
### `v1.x`
```js
```javascript
m.route(document.body, "/booga", {
"/:attr" : {
oninit : function(vnode) {