Problem with ZeroClipboard add tooltip

I am trying to use Zeroclipboard http://code.google.com/p/zeroclipboard/ to copy material to the clipboard and add a tooltip when I hover over the flash. but it does not seem to work.

my html code is:

<div rel="<?php echo $url;?>" class="cp-code">copied code</div>
<div class="test" style="display: none; border: 1px solid #ccc; padding: 8px;">click copy,test,test</div>

My js code: I added the jquery library.

ZeroClipboard.setMoviePath("http://example.com/js/ZeroClipboard.swf");
var clip = null;
var url = '';

function init() {
    clip = new ZeroClipboard.Client();
    clip.setHandCursor( true );

    $('.cp-code').mouseover( function() {
        clip.setText(this.innerHTML);
             $('test').style.display = 'block';
        if (clip.div) {
            clip.receiveEvent('mouseout', null);
            clip.reposition(this);
        } else {
                        clip.glue(this);
                }
        clip.receiveEvent('mouseover', null);
        url = $(this).attr('rel');
    });

    clip.addEventListener('mouseUp', function(client) {
        window.open(url);
    });
  clip.addEventListener('mouseOut', function (client) {
 $('test').style.display = 'none';
   });

    }

$(document).ready(function() {
    init();
});
+3
source share
1 answer

Why do you want this to happen when you hover over the mouse? I am not sure if ZeroClipboard supports this.

, , ZeroClipboard, . clip.setText. "" . jQuery, DOM.

, :

var cpCode = $('.cp-code');
cpCode.each(function()
{
    clip = new ZeroClipboard.Client(); //you can set the movie path here too
    clip.glue($(this)[0]); // The [0] accesses the actual DOM object rather than the jQuery object
    clip.setText($(this).html();
});

, , , . , , , , , , DOM , clip.setText jQuery.

+1

All Articles