zeroclipboard / zeroclipboard-rails

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

Uncaught TypeError: Object [object Object] has no method 'getHTML' #7

Closed hannesfostie closed 10 years ago

hannesfostie commented 11 years ago

Hi

Just tried using your gem together with the code example at https://github.com/HaNdTriX/zeroclipboard-rails/wiki/zeroclipboard-rails---jQuery-Examples

First remark is that clip = new ZeroClipboard.Client(); should be changed to new ZeroClipboard(); as per https://github.com/zeroclipboard/ZeroClipboard/pull/65

After doing so however, I am getting an error on line 12 of the file:

var flash_movie = '<div>'+clip.getHTML(width, height)+'</div>';

It seems getHTML can not be called on clip. I'm at a loss as my javascript skills are very limited. Any idea what's happening?

hannesfostie commented 11 years ago

I took the liberty of changing the wiki page to reflect the change to the constructor I mentioned

myitcv commented 11 years ago

Thanks On 26 Aug 2013 16:11, "Hannes Fostie" notifications@github.com wrote:

I took the liberty of changing the wiki page to reflect the change to the constructor I mentioned

— Reply to this email directly or view it on GitHubhttps://github.com/HaNdTriX/zeroclipboard-rails/issues/7#issuecomment-23269320 .

afriqs commented 10 years ago

Hi,

Same issue here: TypeError: clip.getHTML is not a function

Any idea ?

murdoch commented 10 years ago

Same here,

Uncaught TypeError: Object [object Object] has no method 'getHTML' application.js?body=1:60
(anonymous function) application.js?body=1:60
jQuery.event.dispatch jquery.js?body=1:5096
elemData.handle

Does this gem work with Turbolinks? The wiki article advises to use zclip gem, but the zclip gem advises to use this one. It's slightly confusing.

HaNdTriX commented 10 years ago

The wiki article is obsolete. It tried to solve an position problem, caused by an outdated Version of zeroclipboard. Since then a lot has changed so you should by able to include zeroclipboard as shown in the README.

Please do not try to use the method mentioned in the wiki.

I just removed the misleading wiki-page.

myitcv commented 10 years ago

@HaNdTriX - thanks

murdoch commented 10 years ago

Thanks for clearing that up @HaNdTriX

My problem was being caused by the fact that my clipboard appears in the multi-step form where users can go back and forward between pages. Turbolinks was causing some problems for visitors returning to a page that already had ZeroClipboard objects initialised.

So I just disabled turbolinks on the page in question and now it works fine.

HaNdTriX commented 10 years ago

@murdoch I haven't used rails in awhile. But did you try to remove ZeroClipboard when the page get's unloaded?

Not Tested:

// a Turbolinks-enabled link has been clicked 
document.addEventListener("page:before-change", function(){
  ZeroClipboard.destroy();
});

// the page has been parsed and changed to the new version and on DOMContentLoaded
document.addEventListener("page:change", function(){
  // reinit zeroclipboard here
});
HaNdTriX commented 10 years ago

more info on: https://github.com/zeroclipboard/zeroclipboard/issues/54