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

Problem with apply parameter to getElementsByClassName

Expand Messages
  • brendangibson
    I am upgrading from YUI2.5.3 to YUI2.7.0 and am having some troubles. I get an error with this piece of code:
    Message 1 of 5 , Mar 27 4:23 PM
    • 0 Attachment
      I am upgrading from YUI2.5.3 to YUI2.7.0 and am having some troubles.

      I get an error with this piece of code:

      yd.getElementsByClassName('QandA','div','wall_posts',function () {yd.setStyle(this,'display','block');});

      In YUI2.5.3 it seemed that 'this' was set to each node returned by getElementsByClassName in turn. However in YUI2.7.0 it doesn't seem to be happening this way.

      I noticed that some bugs with getElementsByClassName had been fixed in YUI2.7.0, but they seem to have taken away the functionality that I previously used.

      How do I modify my code to work in YUI2.7.0? My debugging is not giving me any luv.
    • Matt Sweeney
      ... Hi, This sounds like a regression. Go ahead and file a ticket (http://yuilibrary.com/projects/yui2/newticket), and I will take a look. Thanks, Matt
      Message 2 of 5 , Mar 30 5:32 PM
      • 0 Attachment
        brendangibson wrote:
        > I am upgrading from YUI2.5.3 to YUI2.7.0 and am having some troubles.
        >
        > I get an error with this piece of code:
        >
        > yd.getElementsByClassName('QandA','div','wall_posts',function () {yd.setStyle(this,'display','block');});
        >
        > In YUI2.5.3 it seemed that 'this' was set to each node returned by getElementsByClassName in turn. However in YUI2.7.0 it doesn't seem to be happening this way.
        >
        > I noticed that some bugs with getElementsByClassName had been fixed in YUI2.7.0, but they seem to have taken away the functionality that I previously used.
        >
        > How do I modify my code to work in YUI2.7.0? My debugging is not giving me any luv.
        >
        >
        >
        Hi,

        This sounds like a regression. Go ahead and file a ticket
        (http://yuilibrary.com/projects/yui2/newticket), and I will take a look.

        Thanks,

        Matt
      • brendangibson
        ... I found that I could get this to work by passing a parameter through the apply function and using that, rather than this e.g.
        Message 3 of 5 , Mar 31 7:19 AM
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, Matt Sweeney <msweeney@...> wrote:
          >
          > brendangibson wrote:
          > > I am upgrading from YUI2.5.3 to YUI2.7.0 and am having some troubles.
          > >
          > > I get an error with this piece of code:
          > >
          > > yd.getElementsByClassName('QandA','div','wall_posts',function () {yd.setStyle(this,'display','block');});
          > >
          > > In YUI2.5.3 it seemed that 'this' was set to each node returned by getElementsByClassName in turn. However in YUI2.7.0 it doesn't seem to be happening this way.
          > >
          > > I noticed that some bugs with getElementsByClassName had been fixed in YUI2.7.0, but they seem to have taken away the functionality that I previously used.
          > >
          > > How do I modify my code to work in YUI2.7.0? My debugging is not giving me any luv.
          > >
          > >
          > >
          > Hi,
          >
          > This sounds like a regression. Go ahead and file a ticket
          > (http://yuilibrary.com/projects/yui2/newticket), and I will take a look.
          >
          > Thanks,
          >
          > Matt
          >


          I found that I could get this to work by passing a parameter through the apply function and using that, rather than 'this'

          e.g.

          yd.getElementsByClassName('all_heading','div','wall_posts',function (el) {yd.setStyle(el,'display','block');});

          where 'el' is the current element.
        • jrbramble
          When I used this for the first time, I needed to use the onDomReady to get it to work.
          Message 4 of 5 , Mar 31 9:09 AM
          • 0 Attachment
            When I used this for the first time, I needed to use the onDomReady to get it to work.

            --- In ydn-javascript@yahoogroups.com, "brendangibson" <brendangibson@...> wrote:
            >
            > I am upgrading from YUI2.5.3 to YUI2.7.0 and am having some troubles.
            >
            > I get an error with this piece of code:
            >
            > yd.getElementsByClassName('QandA','div','wall_posts',function () {yd.setStyle(this,'display','block');});
            >
            > In YUI2.5.3 it seemed that 'this' was set to each node returned by getElementsByClassName in turn. However in YUI2.7.0 it doesn't seem to be happening this way.
            >
            > I noticed that some bugs with getElementsByClassName had been fixed in YUI2.7.0, but they seem to have taken away the functionality that I previously used.
            >
            > How do I modify my code to work in YUI2.7.0? My debugging is not giving me any luv.
            >
          • Satyen Desai
            Hi, Your apply function should get a reference to the element(s) found... yd.getElementsByClassName( QandA , div , wall_posts , function (el)
            Message 5 of 5 , Mar 31 1:39 PM
            • 0 Attachment
              Hi,

              Your "apply" function should get a reference to the element(s) found...

              yd.getElementsByClassName('QandA','div','wall_posts',
              function (el) {yd.setStyle(el,'display','block');});

              Regards,
              Satyen

              ________________________________________
              From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of jrbramble
              Sent: Tuesday, March 31, 2009 9:09 AM
              To: ydn-javascript@yahoogroups.com
              Subject: [ydn-javascript] Re: Problem with apply parameter to getElementsByClassName

              When I used this for the first time, I needed to use the onDomReady to get it to work.

              --- In ydn-javascript@yahoogroups.com, "brendangibson" <brendangibson@...> wrote:
              >
              > I am upgrading from YUI2.5.3 to YUI2.7.0 and am having some troubles.
              >
              > I get an error with this piece of code:
              >
              > yd.getElementsByClassName('QandA','div','wall_posts',function () {yd.setStyle(this,'display','block');});
              >
              > In YUI2.5.3 it seemed that 'this' was set to each node returned by getElementsByClassName in turn. However in YUI2.7.0 it doesn't seem to be happening this way.
              >
              > I noticed that some bugs with getElementsByClassName had been fixed in YUI2.7.0, but they seem to have taken away the functionality that I previously used.
              >
              > How do I modify my code to work in YUI2.7.0? My debugging is not giving me any luv.
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.