zeroclipboard / zeroclipboard-rails

ZeroClipboard rails gem
http://zeroclipboard.org/
MIT License
125 stars 36 forks source link

Uncaught ReferenceError: ZeroClipboard is not defined #28

Open prokopsimek opened 9 years ago

prokopsimek commented 9 years ago

Added in Gemfile > bundle install > application.js added "//= require zeroclipboard "

Created page with code:

<button class='my_clip_button' data-clipboard-target='fe_text' data-clipboard-text='Default clipboard text from attribute' id='d_clip_button' title='Click me to copy to clipboard.'>
    <b>Copy To Clipboard...</b>
</button>

<div class='demo-area'>
  <h4>
    <label for='fe_text'>Change Copy Text Here</label>
  </h4>
  <textarea cols='50' id='fe_text' rows='3'>Copy me!</textarea>
  <h4>
    <label for='testarea'>Paste Text Here</label>
  </h4>
  <textarea cols='50' id='testarea' rows='3'></textarea>
  <p>
    <button id='clear-test'>Clear Test Area</button>
  </p>
</div>

<script>
  $(document).ready(function() {
    var clip = new ZeroClipboard($("#d_clip_button"))
  });

  $("#clear-test").on("click", function(){
    $("#fe_text").val("Copy me!");
    $("#testarea").val("");
  });
</script>

Error in console:

Uncaught ReferenceError: ZeroClipboard is not defined copy_htmls:168
(anonymous function) copy_htmls:168
fire jquery.js?body=1:3120
self.fireWith jquery.js?body=1:3232
jQuery.extend.ready jquery.js?body=1:3444
completed jquery.js?body=1:3475

copy_htmls:168 == line with "var clip = new ZeroClipboard($("#d_clip_button"))"

rails -v && ruby -v && gem list zeroclipboard-rails
Rails 4.1.6
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
*** LOCAL GEMS ***
zeroclipboard-rails (0.1.0)

Any solutions?

garrettogrady commented 8 years ago

I am having the same problem,.. did you find a solution?

muslih commented 8 years ago

I also have the same problem, and I already solved it by using below: RAILS_ENV=production rake assets:precompile In my production machine