This project is archived and is in readonly mode.
Problem with prototype UJS and pictures as links
-
Santiago Pastorino
Yeah, you should fork rails/prototype-ujs patch and do a pull request
-
Jérémie Horhant (Titinux)
The code on rails/prototype-ujs project is very different from the one in rails-3.0.0.beta3. Am I supposed to correct the code in rails/prototype-ujs ?
-
José Valim
Yup. It seems that Rails master code is almost up to date to rails/prototype-ujs one.
-
José Valim
- Assigned user changed from José Valim to josh
-
Christiaan Van den Poel
Sorry to bump in on this, but I wanted to help on this :)
The problem is related to prototype 1.6 and event delegation.
The eventTarget for the click event isn't the a-tag as you would expect but it's the img-tag. And the 'data-confirm' is only defined on the a-tag, so you would never get the confirm dialog.
I've tried to patch this in the rails/prototype-ujs repo, but as this one is for prototype edge (1.7_rc2) which handles event delegation much better than the 1.6 (stable) version, this is not an issue here.
So the problem only exists for the rails.js version included in the rails/rails repo (which targets prototype 1.6). For this one I've created the following patch.
Currently, the only tags that can have a 'data-confirm' attribute are a-tags and input-tags. When the event.findElement() doesn't return one of these it uses event.findElement('a[data-confirm]') to find the parent a-tag with the attribute set. it searches only for a-tags as these are the only ones who can contain childelements as opposed to input-tags.
Hope this helps
-
Christiaan Van den Poel
Attached the patch
-
Jeremy Kemper
- State changed from new to open
- Milestone cleared.
- Importance changed from to Low
-
Jeremy Kemper
- Importance changed from Low to High
-
Ryan Bigg
Automatic cleanup of spam.
-
Mislav
Sorry this bug didn't get any attention from the prototype-ujs maintainers. Currently that's me, and I only check issues on its github project.
This bug is obsolete, as my refactoring in rails.js worked around this bug a long time ago. If you still experience issues, please report it at the right place. Thanks
(This can be closed)
