Hi,
I am loading a page containing a list and each item has a link, that I
want to observe.
So, my index.jsp has link that executes get_flights() when pressed.
This requests the flight.jsp and onComplete calls show_flights(...),
that displays the list in a <div> and tries to register all the links
in the flight.jsp by calling observe_flight_links()
This function gets all links by their class and sets
select_flight(...) as the observing function.
The problem is that no matter which link I click on the alert displays
"yes: 25" (where 25 is the number of flightlinks in the flight.jsp) -
but it should display "yes: x" where x is the id of the link I
clicked.
Could someone please give me a hint what I am doing wrong?
Regards,
Vincent
-----
function get_flights() {
var myAjax = new Ajax.Request(
"flight.jsp",
{
method: ''get'',
parameters: Form.serialize($(''pax'')),
onComplete: show_flights
}
);
}
function show_flights( originalRequest ) {
$(''flights'').innerHTML =
originalRequest.responseText;
$(''flights'').style.display =
''block'';
observe_flight_links();
}
function observe_flight_links() {
var thelinks = $$(''.flightlink'');
for (var i = 0; i < thelinks.length; i++) {
thelinks[i].observe(''click'',
function(event) {
select_flight(event, i);
});
}
}
function select_flight(event, f){
alert(''yes: '' + f);
}
-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---