Skip to content

Commit

Permalink
Fixed spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepavlov committed Jul 16, 2016
1 parent 7fcf864 commit 119fb0d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ This directive assumes you are using it *inside* of some sort of list of element

First, you can see the `id`. In this case, it is being used to inform us of *where in my array of tasks is this item?*.

When the list is changed, `drop` is called, and we run `handleDrop` (but we can use any function in our `methods` in the Vue instance), which calls with 2 arguments `(draggedElement, dropppedOnElement)`. This way we can do a swap in our data. For the `example.html`, we use the elements `id` as the index in our data.
When the list is changed, `drop` is called, and we run `handleDrop` (but we can use any function in our `methods` in the Vue instance), which calls with 2 arguments `(draggedElement, droppedOnElement)`. This way we can do a swap in our data. For the `example.html`, we use the elements `id` as the index in our data.

Since we get these 2 elements, we can then do a normal array swapping dance, which looks like this:

```js
var placeholder = this.tasks[draggedElement.id];
this.tasks.$set(draggedElement.id, this.tasks[dropppedOnElement.id]);
this.tasks.$set(dropppedOnElement.id, placeholder);
this.tasks.$set(draggedElement.id, this.tasks[droppedOnElement.id]);
this.tasks.$set(droppedOnElement.id, placeholder);
```

You can use whatever you want for the `$index` attribute. Maybe you want to use `data-index`? Then just use `draggedElement.getAttribute('data-index')` to grab the index for that item in your data.
Expand Down

0 comments on commit 119fb0d

Please sign in to comment.