Page 1 of 1

Stock component - passing arguments to event function

Posted: 19 March 2013, 23:00
by emanueles
Hello,
I need to pass an argument to the event function for the onChangeSelection event of a Stock component.
I read the documentation and I found this:

onChangeSelection

This callback method is called when the player select/unselect an item of the stock.
You can connect this to one of your method like this:
dojo.connect( this.myStockControl, 'onChangeSelection', this, 'onMyMethodToCall' );
(...)

onMyMethodToCall: function( control_name )
{
// This method is called when myStockControl selected items changed
var items = this.myStockControl.getSelectedItems();
// (do something)
},


I think that control_name is an argument for the function onMyMethodToCall, but I'm not able to understand which type of variabile it is and how to use it. I tried to insert the argument in my code, but an error occurred.
Could someone help me?

Bye
Emanuele

Re: Stock component - passing arguments to event function

Posted: 20 March 2013, 17:57
by sourisdudesert
Hello Emanuele,

The "control_name" is the ID (the "DOM" id) of the <div> container of your stock control.

Using "control_name", you can use the same callback method for different Stock control and see which one trigger the method.

Does this answer your question?

Cheers,

Re: Stock component - passing arguments to event function

Posted: 20 March 2013, 21:04
by emanueles
Yessss! :)
That's the answer I needed.
Thank you!

Cheers