Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vue-paginate
# vue-paginate [![CDNJS version](https://img.shields.io/cdnjs/v/vue-paginate.svg)](https://cdnjs.com/libraries/vue-paginate)

> This version only works with Vue 2.0. For Vue 1.0, check out the [1.0 branch](https://github.com/TahaSh/vue-paginate/tree/1.0).

Expand Down Expand Up @@ -158,6 +158,50 @@ To fix this issue we have to tell our `PaginateLinks` to wait for its companion
```
*So the bottom line is this: `<paginate>` component should always be rendered before `<paginate-links>` component.*

### Using it inside a component's slot

`Paginate` and `PaginateLinks` components get their current state from the parent component they're used in. You can find that state defined inside an object called `paginate`. For example, if your pagination is named `languages`, its state will be defined inside `paginate.languages`.

But what if those components are used inside a [slot](https://vuejs.org/v2/guide/components-slots.html#Slot-Content)? In this case, its parent component will be the slot's component (not the component it's defined in).

In this case we have to tell our pagination components where they can find the component that contains their state. We can do so using the `container` prop.

Although both components, `Paginate` and `PaginateLinks`, use the same prop name, they take different values. `Paginate` component just needs the reference to the parent component that has its state. That value is usually `this`.

`PaginateLinks`, however, takes an object with two values: `state` and `el`.

`state` takes the current state object of the pagination. This value can be, for example, `paginate.languages`.

For `el` we should pass a reference to the component that contains `Paginate` component. In most cases it will be the component with the slot. For example: `$refs.layout`.

#### Example

Note: this example is based on the previous example.

``` html
<div id="app">
<layout ref="layout">
<paginate
name="languages"
:list="langs"
:per="2"
:container="this"
>
<li v-for="lang in paginated('languages')">
{{ lang }}
</li>
</paginate>
<paginate-links
for="languages"
:container="{
state: paginate.languages,
el: $refs.layout
}"
/>
</layout>
</div>
```

### Types of paginate links

`vue-paginate` provides us with three different types of pagination links:
Expand Down Expand Up @@ -431,4 +475,4 @@ Note that this feature works on all link types – full links, simple links, and

[MIT](http://opensource.org/licenses/MIT)

Copyright (c) 2016–2017 Taha Shashtari
Copyright (c) 2016–2017 Taha Shashtari
Loading