[ 3 posts ]

Brendan Barr

  • Username: bbarr
  • Joined: Tue Jul 26, 2011 8:30 am
  • Posts: 1
  • Offline
  • Profile

Auto-Adding ID's to HTML elements

Post Posted: Tue Jul 26, 2011 10:15 am
+0-
Hi all,

I am working on a rather large ecommerce application, and we recently noticed that many of our HTML elements are being given YUI generated ID's.

Something like: <div id="yui_3_4_5_67893243"></div>

This appears to be happening indiscriminately, and since it is not a trivial process, we would love to find the source of the problem in our code, or in YUI's. Any thoughts on why/when YUI would do this ID generation? And how it could be running a bit rampant?

Thanks!

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile

Re: Auto-Adding ID's to HTML elements

Post Posted: Mon Aug 01, 2011 11:46 am
+0-
Y.Node does this in the constructor. It allows a huge optimization, because all the instances of Y.Node are stored in a map, so if you call Y.one() again later for the same node, it will return the same instance.

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 620
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Offline
  • Profile

Re: Auto-Adding ID's to HTML elements

Post Posted: Tue Aug 02, 2011 5:07 am
+0-
It's not only about optimization by caching. It is an important part of the Event system and the Widget infrastructure. For instance, there is a function called Widget.getByNode() that uses that id to match DOM nodes to widgets. That allows for event propagation in widgets and other cool stuff.
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum