www.webdeveloper.com
Results 1 to 5 of 5

Thread: Unable to Access Custom Property

  1. #1
    Join Date
    Apr 2004
    Posts
    12

    Unable to Access Custom Property

    Hi,

    I'm having trouble accessing a custom property that I've created for an object. Does anyone see the problem with this code? this.imageSrcs is undefined inside of getImages.

    Gallery.prototype.imageSrcs = new Array();

    Gallery.prototype.getImages = function(json) {
    if (json) {
    for (var row = 0; row < json.rows.length; row++) {
    this.imageSrcs.push(json.rows[row].c[0].v);
    }
    }
    }

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

  3. #3
    Join Date
    Apr 2004
    Posts
    12
    Yes, it's a callback function that is executed after data has been read from a spreadsheet. How would I go about getting access to this property then?
    Last edited by donnapep; 01-21-2011 at 11:29 PM.

  4. #4
    Join Date
    Mar 2009
    Posts
    523
    I don't know if this is your problem or not. One thing I don't know is what 'Gallery' really is. Is it a constructor? Consider the following:

    function blob(){}; //create a constructor function for a 'blob' object
    Code:
    var v = new blob(); //create a blob
    
    v.prototype.imageSrcs = new Array('1','2','3');//this causes an error when you use it on an instance of a blob
    blob.prototype.imageSrcs = new Array('1','2','3');  //this works, because blob is a constructor
    
     
    
    
    window.onload = function(){alert(v.imageSrcs);}  //this works--it will display your array
    
    window.onload = function(){alert(blob.imageSrcs);}  // this won't work--imageSrcs shows as undefined
    I hope this makes sense.

  5. #5
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles