views:

33

answers:

1

How do I get the particular element instance when an event is registered for multiple elements having same class ?

Code

Event.observe(document, 'dom:loaded', initBookingHistory); 

function initBookingHistory() 
{ 
    hideJourneyDetails(); 
    ObserveJourneyDetailsForClick(); 
} 

function ObserveJourneyDetailsForClick()
{ 
    $$('.Journey_Details div#Journey_Detail div.head h2 span.wrap').each(function(ele)
    { 
         Event.observe(ele,'click', showOrHideJourneyDetails(ele));
    }) 
} 

function showOrHideJourneyDetails(ele)
{ 
    ele.show(); 
}

Error

I get an "Handler is undefined" error

A: 

Do you mean events like onClick? If that's what you think, you use onclick="do_something(this)"

usoban
Event.observe(document, 'dom:loaded', initBookingHistory);function initBookingHistory() { hideJourneyDetails(); ObserveJourneyDetailsForClick();}function ObserveJourneyDetailsForClick(){ $$('.Journey_Details div#Journey_Detail div.head h2 span.wrap').each(function(ele){ Event.observe(ele,'click', showOrHideJourneyDetails(ele));})}function showOrHideJourneyDetails(ele){ ele.show();}I get an "Handler is undefined" error for the following code
Please add this code to your question and make this block code block.
rahul

related questions