#94 ✓not_for_core
ronin-13570 (at lighthouseapp)

Add Anchor.request ala Form.Request

Reported by ronin-13570 (at lighthouseapp) | 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

    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;
      }
    })
    
  • ronin-13570 (at lighthouseapp)

    ronin-13570 (at lighthouseapp) 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.

  • ronin-13570 (at lighthouseapp)

    ronin-13570 (at lighthouseapp) 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

    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 : )

  • ronin-13570 (at lighthouseapp)

    ronin-13570 (at lighthouseapp) 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 :)

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:11 AM

    • Tag set to element, section:dom

    [not-tagged:"dom" tagged:"section:dom" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:12 AM

    • Tag changed from element, section:dom to section:dom

    [not-tagged:"element" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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.

Shared Ticket Bins

People watching this ticket

Attachments

Pages