Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:45:01+00:00 2026-06-01T13:45:01+00:00

OK, I confess at the outset I’m over my head a bit here. I’ve

  • 0

OK, I confess at the outset I’m over my head a bit here.

I’ve had some code working fine. I created a global array variable z1=[]; and then stored ZeroClipboard objects in the array using the unique reference key r with the following code. (This may be evil in itself, but it worked.)

function zc(r){
    var a="RP"+r,b="RDC"+r,c="RP"+r;
    z1[r]=new ZeroClipboard.Client();
    z1[r].addEventListener('mouseDown',function(client){z1[r].setText(document.getElementById(c).innerHTML);});
    z1[r].addEventListener('complete',function(client,text){$('#'+a).aH("#D6EBFF",1000);});
    z1[r].glue(a,b);}

I’ve recently realised how desperately wicked it is to have z1 as a global variable, so I’m trying to mend my ways and create an object to bound the whole business. But it’s not working…

I’ve done the following:

var zc={
    z1: [],

    add:function(r){
        var a="RP"+r,b="RDC"+r,c="RP"+r;
        z1[r]=new ZeroClipboard.Client();
        z1[r].addEventListener('mouseDown',function(client){z1[r].setText(document.getElementById(c).innerHTML);});
        z1[r].addEventListener('complete',function(client,text){$('#'+a).aH("#D6EBFF",1000);});
        z1[r].glue(a,b);}
}

And I’m now calling zc.add(r) instead of zc(r) like before.

The Firebug error I’m getting is z1 is not defined. Why can my 'add' method not see my 'z1' property?

[Oh, and before someone asks why I don’t just put z1 in zc as it is, it’s because I access z1 from elsewhere in the code, and so I’m going to add further methods to the object.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:45:02+00:00Added an answer on June 1, 2026 at 1:45 pm

    Change z1[r] to this.z1[r]

    I might also suggest setting it to a variable in the scope to avoid the lookups.

    var zr = this.z1[r] = new ZeroClipboard.Client();
    zr.addEventListener()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I confess at the outset that I dislike and don't really understand regex properly.
I must confess I'm a bit of a noob when it comes to MSBuild
I confess I'm having a really bad time here. I have a C program
I have to confess I've had this question for a very long time and
I have to confess that I hate membership provider. The default implementation is not
I should confess I do not even own a Mac, I have done Windows
I have just rolled a custom configuration section, created an accompanying schema document for
I confess I am a noob to asp.net and web forms. I'm having an
I will confess I'm very new to Python and I don't really know what
I must confess that today is my first day using either Sweave or LaTeX.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.