Thursday, 15 May 2014

javascript - ZeroClipboard on dynamically generate elements? -



javascript - ZeroClipboard on dynamically generate elements? -

i have set of divs dynamically generated. within them clipboard icons, that, when clicked, re-create element's data-hash clipboard (not yet functional). these icons have class '.fa-clipboard' fontawesome.

minimal code:

<script> $(document).ready(function(){ var clip = new zeroclipboard($('.fa-clipboard'), { moviepath : 'plugins/zeroclipboard.swf' }); $(document).on('click', "#content .fa-clipboard", function(){ //alert(window.location + $(this).data('hash')); clip.settext( window.location + $(this).data('hash') ); clip.glue( ); }); }); </script> <body> <div id="wrapper"> <div id="content"> <!--dynamically generated elements in here--> </div> </div> </body> </head> </html>

the click function works properly, it's matter of setting clipboard.

javascript jquery html zeroclipboard

No comments:

Post a Comment