Carousel JavaScript Events

UI Components for JSF
Post Reply
onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

09 Jun 2010, 00:16

Is there a way to know the selected image (currently visible image) using JavaScript?

Are there any JavaScript events that fire when the carousel scrolls from one image to another. In short is there any JavaScript support for the Carousel widget?

Thanks.
Jonathan Ekwempu
TobiSoft Inc.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Jun 2010, 11:20

Take a look at client side api of carousel, there are lots of methods and events you can use.

http://developer.yahoo.com/yui/docs/YAH ... ousel.html

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

09 Jun 2010, 14:36

Thanks for pointing me to the events. I will experiment with the events.
Jonathan Ekwempu
TobiSoft Inc.

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

09 Jun 2010, 17:37

I could not relate what I saw in the Yahoo site to the JSF carousel widget. Could you please (as an example)show how to implement "itemSelected" event for a JSF carousel widget.

I tried onitemselected="handleItemSelected();"

function handleItemSelected(){
alert("In handleItemSelected()");
}

It did not fire the event.

I think a good example will help. I looked at your documentation but could not find any related examples.

Thanks.
Jonathan Ekwempu
TobiSoft Inc.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Jun 2010, 13:17

Sure Jonathan, assume you have a carousel like the following, make sure you have defined a widgetVar.

Code: Select all

<p:carousel widgetVar="mycarousel" ... >
   //items
</p:carousel>

Code: Select all

<script type="text/javascript">
function handleItemSelected(newValue){
   alert("In handleItemSelected: " + newValue);
}

mycarousel.on('itemSelected', handleItemSelected);
</script>
Your script should run after document is loaded, body onload event would be fine. Or place your script after p:carousel.

onyii5119
Posts: 112
Joined: 25 Nov 2009, 00:22

10 Jun 2010, 23:07

The code snippet was really helpful. Keep up the good work.

Thanks.
Jonathan Ekwempu
TobiSoft Inc.

darshptl2
Posts: 2
Joined: 30 Jul 2021, 02:42

30 Jul 2021, 02:51

Hi,
Can you please see to put your documentation page back? Right now the link https://developer.yahoo.com/yui/docs/YA ... ousel.html
says the page cannot be found.. Getting to know the list of carousel events will be helpful please. Thanks ahead!

Darshan

darshptl2
Posts: 2
Joined: 30 Jul 2021, 02:42

30 Jul 2021, 03:10

@cagataycivici can you please also point to a list of current api events developed for the carousel. I am new to PrimeNG and carousel is the first control I am using in my coding, so help is very much appreciated. Thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests