Search code examples
prototypejs

prototype newbie, Element.identify(element) vs Element#(identify)


i have the following in my code and want to add all of them to Droppables, using Droppables.add, which means i need the id of each of the elements.

<div id="seating1" class="unbooked"></div>
<div id="seating2" class="unbooked"></div>
<div id="seating3" class="unbooked"></div>
<div id="seating4" class="unbooked"></div>

my read of the prototype documentation is that the following should be interchangeable and should both return the string 'seating1':

$('seating1').identify

and

Element.identify($('seating1'))

i've reduced what i actually do, as i could clearly just do Droppables.add('seating1'). what i'm really doing is $$('.unbooked') and then extracting the id using identify across the elements. but only the second form works. i'd prefer to use the first form as it's more oo-friendly.

when i run it from the firebug console, the first form returns a function. the second form gives me 'seating1' as expected.

what am i missing? this would seem pretty fundamental for me to figure out if i want to have any luck.

as always, any help or insight is appreciated.

thanks, hubert


Solution

  • should be:

    $('seating1').identify()
    

    so full code would be something like:

    $$('.unbooked').each(function(el){
      $(el).identify();
      // or even ...
      $(el).id;
    });