Results 1 to 2 of 2

Thread: javascript problem

  1. #1
    Join Date
    Apr 2006
    Location
    italy
    Posts
    11

    javascript problem

    Any javascript guru that can have a look at the folowing code?

    window.application.main = function(){
    var d = this.getClientWindow().getClientDocument();
    var bs = new QxBarView;
    for(var i=[0];i<[3];i++){
    var bvb = new QxBarViewButton("page"+i, [0]);
    bs.getBar().add(bvb);
    var p = new QxBarViewPage(bvb);
    var galleryList = [];
    galleryList.push({
    width : [350],
    height : [350],
    thumbWidth : [64],
    thumbHeight : [64],
    comment : "comment",
    title : "title",
    src : "pic.gif"
    });

    var gallery = new QxGallery(galleryList);
    gallery.id=i;
    gallery.addEventListener("click", function(e){
    alert(gallery.id);
    });

    p.add(gallery);
    bs.getPane().add(p);
    }
    d.add(bs);
    }


    it uses qooxdoo.
    basically, what this code is doing is creating 3 galleries and adding 3 event handlers to them; whenever i click a gallery, i expect to get a message box containing the id of that gallery. however, no matter what gallery i click, i get the last added gallery id, 2.
    i have the feeling that this isnt a qooxdoo lib issue, but my bad understanding of how js works. i would expect that clicking the 1st gallery to see 0, the 2nd 1 and so on.
    anyone that can shed some light on this?

  2. #2
    Join Date
    Apr 2006
    Location
    italy
    Posts
    11
    I got it working, if anybody is interested.

    gallery.addEventListener("click", function(e){
    //alert(gallery.id);
    alert(this.id);
    });

Similar Threads

  1. Problem with javascript Slideshow and transparent PNG files
    By moez in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 20 Jan 2006, 02:56 PM
  2. Difficult Javascript Problem!
    By ecampsite.co.uk in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 07 Dec 2005, 08:12 AM

Posting Permissions

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