Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

e.data is undefined #5

Open
ghost opened this issue Dec 5, 2014 · 0 comments
Open

e.data is undefined #5

ghost opened this issue Dec 5, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 5, 2014

hello, thank you for the useful plugin!

I downloaded jquery.zeroclipboard v0.2.0
added to my script, it works, as it copy to the clipboard the value I pass it, but it doesn't seem to behave like in the examples...
if the object passed to my function after 'copy' or 'aftercopy' is triggered is : e , e.data is undefined, and I cannot figure out where data is stored...

This is my implementation:

var mOdj = {
    copy_column : function(e) {

        var 
            rText = [], idx = 0;

        rText[idx++] = 'dummy1';
        rText[idx++] = 'dummy2';
        rText[idx++] = 'dummy2';

        console.log(e);
        // Clear out any existing data in the pending clipboard transaction
            e.clipboardData.clearData();
            // Set your own data into the pending clipboard transaction
        e.clipboardData.setData("text/plain", rText.join("\n"));
        // console.log(e);
        e.preventDefault();
    },

    copy_verify : function(e) {
        console.log(e);
        if (e.success["text/plain"] === true) {
            console.log("Copy succeeded. Yay! Text: e.data["text/plain"]);
        }
        else {
            console.log("Copy failed... BOOOOOO!!!");
        }   
    },

    copy_errors : function(errorEvent) {
        console.log(e);
    }

}

$(document).ready(function(){ 
    $('#container')
        .on('copy', 'img.cClipBtn', mOdj.copy_column)
        .on('aftercopy', 'img.cClipBtn', mOdj.copy_verify)
        .on('copy-error', 'img.cClipBtn', mOdj.copy_errors);

}); 

inside copy_verify(e), this line:
console.log("Copy succeeded. Yay! Text: e.data["text/plain"]);
returns a e.data undefined error

any idea on what I am missing?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants