Loading ...
Sorry, an error occurred while loading the content.

Re: Referencing my Carousels via Javascript

Expand Messages
  • Scribner, Craig
    Thank you Gopal! That works! From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of gopalarathnam_v Sent: Friday, December
    Message 1 of 4 , Dec 5, 2008
    • 0 Attachment

      Thank you Gopal! That works!

       

      From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of gopalarathnam_v
      Sent: Friday, December 05, 2008 12:47 PM
      To: ydn-javascript@yahoogroups.com
      Subject: [ydn-javascript] Re: Referencing my Carousels via Javascript

       

      --- In ydn-javascript@yahoogroups.com, "craigdscribner" <craig.scribner@...> wrote:

      >
      > I want to have some control buttons above my Carousels that can remove
      > all the carousel items and replace them with new ones, change the size
      > and the visibilityNum.
      >
      > I can see how to do all these things when I load the page initially,
      > but I don't know how to reference and change them later on.
      >
      > For example, if I insert an HTML button on the page that says
      > onclick="carousel.removeItem(0)" I get a javascript error saying
      what
      > the heck is a carousel?
      >
      > I realize that the carousel I want is contained in a div called
      > Container. But I still can't figure out a way to make something like
      > this work:
      > "document.getElementById('container').carousel.removeItem(0)".
      Again,
      > it says thet carousel is undefined.
      >
      > Can you offer some guidance? thanks!
      >

      The YUI Carousel offers a static method "getById" that can be used to get the instance of
      the Carousels in your page. For example, assuming you have two Carousels in your page
      with element IDs viz., "carousel1" and "carousel2", then:

      // the following call returns the Carousel instance "carousel1"
      var carousel1 = YAHOO.widget.Carousel.getById("carousel1");
      // you can use any YUI Carousel method on carousel1 now
      // carousel1.removeItem(0);

      Similarly, passing "carousel2" returns the instance of the second Carousel (that has the ID
      - carousel2).

      --
      Gopal Venkatesan
      http://g13n.in/

      Note: if you see question marks (?????) after my name in the From header, then your mail
      tool is not Unicode enabled! You should see my name (Gopal Venkatesan) in Hindi (गोपाल
      वेंकटेसन)

    Your message has been successfully submitted and would be delivered to recipients shortly.