Container option (#368)

* Allow container option to fix bugs related to bootstrap modals etc.

* Updated readme to reflect addition of container option

* Name link

* Removed test log

* Remove unwanted whitespace

* Refactored description
This commit is contained in:
Peder Johnsen
2017-05-29 22:17:26 +01:00
committed by Zeno Rocha
parent 4065080a17
commit f42b57067d
7 changed files with 69 additions and 23 deletions

View File

@@ -145,6 +145,15 @@ new Clipboard('.btn', {
});
```
For use in bootstrap modals or with any other library that changes the focus you'll want to set the focused element as the `container` value.
See [Issue #155 (comment)](https://github.com/zenorocha/clipboard.js/issues/155#issuecomment-273124130)
```js
new Clipboard('.btn', {
container: document.getElementById('#modal')
});
```
Also, if you are working with single page apps, you may want to manage the lifecycle of the DOM more precisely. Here's how you clean up the events and objects that we create.
```js