Clipboard.js: t is null

Created on 12 Jan 2016  路  3Comments  路  Source: zenorocha/clipboard.js

I have installed clipboard.js on a website, but when the page loads I get the following error in firebug

The relevant code is as follows

Most helpful comment

@zenorocha Ah, sorry, I got it. I should move initialization to the end of the body element. You may emphasize this moment in the documentation or use live handlers...

All 3 comments

Closing this one since no code has been provided, but I'm assuming it's duplicated from https://github.com/zenorocha/clipboard.js/issues/141

@zenorocha I have exactly the same error. I've added the following code to the header of the page:

  <script src="{% static "clipboard/dist/clipboard.js" %}" type="text/javascript"></script>
  <script type="text/javascript">
    new ClipboardJS('.btn');
  </script>

I have two copy buttons with class btn on my page. Buttons doesn't work and I see the same exception in the console.

When I change to the non-minified version, I get:

TypeError: elements is null
[袩芯写褉芯斜薪械械]
clipboard.js:789:9
delegate
http://localhost:8000/static/clipboard/dist/clipboard.js:789:9
listenSelector
http://localhost:8000/static/clipboard/dist/clipboard.js:417:12
listen
http://localhost:8000/static/clipboard/dist/clipboard.js:358:16
listenClick
http://localhost:8000/static/clipboard/dist/clipboard.js:622:34
Clipboard
http://localhost:8000/static/clipboard/dist/clipboard.js:596:13
<邪薪芯薪懈屑薪邪褟>
http://localhost:8000/reports/:24:5

@zenorocha Ah, sorry, I got it. I should move initialization to the end of the body element. You may emphasize this moment in the documentation or use live handlers...

Was this page helpful?
0 / 5 - 0 ratings