Add Anchor.request ala Form.Request
Reported by Simon Harris | May 13th, 2008 @ 02:33 AM
It's nice to have a very simple way to submit a link via Ajax much like the way you can with Form.
Comments and changes to this ticket
-
Juriy Zaytsev May 13th, 2008 @ 05:19 AM
- → State changed from new to not_for_core
It's actually trivial to add such method, but what's the use case?
Element.addMethods('a', { request: function(element, options) { if (!(element = $(element)) return; new Ajax.Request(element.href, options); return element; } }) -
Simon Harris May 13th, 2008 @ 05:27 AM
Sure, which is why I attached pretty much the same code when I originally created the ticket (although certainly not as robustly as yours) ;-)
I'm attaching behaviour to elements in javascript and quite often I want to do some processing when an anchor is clicked. This might be to just simply invoke the request using XHR or more likely to do some processing prior to executing the request and/or add onX processing and do something with the response.
-
Simon Harris May 13th, 2008 @ 05:28 AM
OK so I thought I had uploaded the file. In any event. It seems internally consistent to have anchor.request() given that there is form.request(). Principle of Least Surprise ;-)
-
Juriy Zaytsev May 13th, 2008 @ 05:35 AM
I'm against introducing another global variable - Anchor - as I see it in your ticket. Having a #request method on anchors, though, might be useful, though I have never needed such functionality : )
-
Simon Harris May 13th, 2008 @ 05:41 AM
Fair enough...in my use I don't actually have an Anchor global, I, funnily enough, uploaded it that way because it fit the style used for Form hehehe.
I guess the general way people do this stuff is to generate the ajax links using say rails helpers. However for those of us in the unobstrusive camp, it would be nice :)
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
