Wednesday, March 21, 2012

Parameters passing with ClickBehavour

I have read Wilco's post:

But still cannot pass a parameter to a function call.

functoin MyHandler(sender, args) {
var dc = sender.get_dataContext();
var descr = dc.getProperty("Description");


<atlas:Button ...>
is the example, on the page, but I dont get how I can get bind for example an ID to be passed to my function.

Thanks all :)


you are using the function as an event handler (for the click event) thus it's normal that you cannot pass parameters to it; only the object that raises the event (the Button instance in this case) should pass parameter to event handlers.

What you could do is retrieve the ID parameter in the event handler. Which are your requirements?
Thanks for your reply :)

I have a datasource retrieved from the web service and is binding it toa list. For each row of the list, there is a "link" where the user canclick on to call the JS function passing in the ID that hopefully canbe binded to.

For example:

Data Source:

Name || ID

Joe Doe || 0
Garbin || 1

And the list will be outputtied as:

<a href="" onclick=functiontoCall( 0 )> Joe Doe </a>
<a href="" onclick=functiontoCall( 1 )> Garbin </a
Something similar to the above is what I am trying to do.

Thanks :)

No comments:

Post a Comment