mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Adds advanced usage docs
This commit is contained in:
parent
c989d6a5d4
commit
23504403d1
20
index.html
20
index.html
@ -130,6 +130,26 @@ allowtransparency="true" frameborder="0" scrolling="0" width="156" height="30"><
|
||||
Copy to clipboard
|
||||
</button></code></pre>
|
||||
|
||||
<h1 id="advanced-usage">Advanced Usage</h1>
|
||||
|
||||
<p>If you don't want to modify your HTML, there's a pretty handy imperative API for you to use. All you need to do is declare a function, do your thing, and return a value.</p>
|
||||
|
||||
<p>For instance, if you want to dynamically set a <code>target</code>, you'll need to return a Node.</p>
|
||||
|
||||
<pre><code class="js">new Clipboard('.btn', {
|
||||
target: function(trigger) {
|
||||
return trigger.nextElementSibling;
|
||||
}
|
||||
});</code></pre>
|
||||
|
||||
<p>If you want to dynamically set a <code>text</code>, you'll return a String.</p>
|
||||
|
||||
<pre><code class="js">new Clipboard('.btn', {
|
||||
text: function(trigger) {
|
||||
return trigger.getAttribute('aria-label');
|
||||
}
|
||||
});</code></pre>
|
||||
|
||||
<h1 id="events">Events</h1>
|
||||
|
||||
<p>There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation.</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user