fireEvent takes two arguments:

the event ('callback')

args (an object, or an array)

the args object is passed to your function as you would expect, but consider
these two examples:

this.addEvent('foo', function(number) {
  alert(number);
});
this.fireEvent('foo', 1); //alerts "1"

this.addEvent('foo', function(x, y) {
  alert(x + ' / ' + y);
});
this.fireEvent('foo', [1, 2]); //alerts "1 / 2"

When you pass an array, those become arguments. If you want an array to BE
an argument you need to wrap it:

this.addEvent('foo', function(arr) {
  alert(arr[0] + '/' + arr[1]);
});
this.fireEvent('foo', [[1,2]]);


On Wed, Dec 23, 2009 at 3:58 PM, mmjaeger <[email protected]> wrote:

> hello
> I've a class that initiates a second class with a callback function -
> the class that gets called has the following event:
> this.fireEvent('callback', someItems);
>
> if I check the type of someItems before the callback, it's an array
> with 15 items
>
> when I check what I get back in the callee class, it's an object with
> only the first item???
>
> Could anybody please tell me what I'm missing here?
>
> thank you in advance for your help.
>

Reply via email to