Skip to content

Commit

Permalink
docs: move initialization section
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Aug 12, 2018
1 parent c23b609 commit a3799f1
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions README.md
Expand Up @@ -79,27 +79,6 @@ With the above example, the input value of `.src` is copied to `.dest` on each i

[See the demo][Mirroring Example]

# Initialization

There are 2 ways to initialize components:

1. [When document is ready][DOMContentLoaded] (automatic).
2. When `capsid.prep()` is called (manual).

All components are initialized automatically when document is ready. You don't need to care about those elements which exist before document is ready. See [Hello Example][] or [Clock Example][] for example.

If you add elements after document is ready (for example, after ajax requests), call `capsid.prep()` and that initializes all the components.

```js
const addPartOfPage = async () => {
const { html } = await axios.get('path/to/something.html')

containerElemenent.innerHTML = html

capsid.prep() // <= this initializes all the elements which are not yet initialized.
})
```

# :cd: Install

## Via npm
Expand All @@ -125,6 +104,26 @@ In this case, the library exports the global variable `capsid`.
```js
capsid.def('my-component', MyComponent)
```
# Initialization

There are 2 ways to initialize components:

1. [When document is ready][DOMContentLoaded] (automatic).
2. When `capsid.prep()` is called (manual).

All components are initialized automatically when document is ready. You don't need to care about those elements which exist before document is ready. See [Hello Example][] or [Clock Example][] for example.

If you add elements after document is ready (for example, after ajax requests), call `capsid.prep()` and that initializes all the components.

```js
const addPartOfPage = async () => {
const { html } = await axios.get('path/to/something.html')

containerElemenent.innerHTML = html

capsid.prep() // <= this initializes all the elements which are not yet initialized.
})
```

# Capsid Lifecycle

Expand Down

0 comments on commit a3799f1

Please sign in to comment.