All good points. And just to clarify what my position was... I was more or
less just trying to urge you to be pragmatic and not get all hung up on this
unobtrusive javascript stuff, just for the sake of itself. If what you have
works for this given task, don't get too bent out of shape trying to rework
it.
On 3/13/07, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>
>
> I see two things that could help:
>
> 1) To use IDs indeed: just add an infix/suffix to your IDs, e.g.
>
> <td><img id="img_<?= $id ?>_edit" src="..." /></td>
> <td><img id="img_<?= $id ?>_delete" src="..." /></td>
>
> 2) Why create one click handler per image?! Leverage bubbling, and
> create a single, non-server-generated (bye-bye this convoluted use of
> AJAX!) handler at the table level, that uses Event.element(e) to check
> it's dealing with one of your images. Something like:
>
> Event.observe('yourTableId', 'click', function(e) {
> var elt = Event.element(e);
> if (elt.tagName != 'IMG')
> return;
> Event.stop(e);
> var data = elt.id.split('_');
> window.location.href = data[2] + '_site.php?id=' + data[1];
> });
>
> Notice you don't need the custom classes anymore...
>
> From a more conceptual standpoint, this *doesn't* degrade gracefully:
> with no JS, those images are unclickable, and your functionality is
> lost. These should be <input type="image" /> in a <form>, and you could
> intercept the form's submission through JS to rewrite the request
> without those pesky x/y arguments that you find "confusing to users."
>
> --
> Christophe Porteneuve a.k.a. TDD
> "[They] did not know it was impossible, so they did it." --Mark Twain
> Email: [EMAIL PROTECTED]
>
> >
>
--
Ryan Gahl
Application Development Consultant
Athena Group, Inc.
Inquire: 1-920-955-1457
Blog: http://www.someElement.com
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---