tags:

views:

18

answers:

1

I am using the yui progress bar to display ratings for a list of items. I know the progress bar inherits the "on" method, but I'm not sure how to capture where in the progress bar the user is clicking. I'd like to get an int or double from that event. Is this possible?

+1  A: 

ProgressBar provides no direct way to do that. However, since it inherits the on method which allows you to subscribe to events from the widget container, you can subscribe to the click event and get the X,Y coordinates of the click and compare them to the top-left corner:

myProgressBar.on('click', function (ev) {
     var xyClick = YAHOO.util.Event.getXY(ev);
     var xyProgressBar = YAHOO.util.Dom.getXY(this.get('element'));
     // now you make the arithmetic
});

getXY returns an array with two elements, the x and y coordinates. It would be easier to use getX or getY depending on the orientation of the ProgressBar

Satyam
Satyam, I've read many of your tutorials and posts on YUI. Thanks for taking the time to respond.
TheDudeAbides