# Ajax with Radius Tag in Frontend

**URL:** <https://www.ruby-forum.com/t/ajax-with-radius-tag-in-frontend/149220>\
**Category:** Radiant CMS\
**Created:** [September 22, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/ajax-with-radius-tag-in-frontend/149220 "2008-09-22T16:20:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal\_n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9c0ed/32.png) [@pascal\_n](https://www.ruby-forum.com/u/pascal_n)\
**Post date:** [September 22, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/ajax-with-radius-tag-in-frontend/149220/1 "2008-09-22T16:20:09Z")

</div>

Hi

I started with Radiant a few days ago and want to use Ajax in the  
fronted.

I would like to do it as radius tag so that I can use functionality in  
layouts and snippets. Everywhere I searched for possible solution I got  
following article: [AJAX Controller/View Methods/Helpers in Extension/Tag Block - Radiant CMS - Ruby-Forum](http://www.ruby-forum.com/topic/111927#new)

So I tried following:

The Tag module:

module CustomerReferencesTags  
include Radiant::Taggable

tag ‘customerReferences:index’ do |tag|  
link\_to\_remote ‘A’, :url =\>{ :action =\> ‘ajaxtest’ }  
end  
end

The result of this try was "undefined method “link\_to\_remote’ for #”.

Does somebody know the current way to do it in Radiant or knows a good  
turtorial?

Thx a lot for help.

Pascal

---

<div class="post-metadata">

**Author:** ![pascal\_n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9c0ed/32.png) [@pascal\_n](https://www.ruby-forum.com/u/pascal_n)\
**Post date:** [September 22, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/ajax-with-radius-tag-in-frontend/149220/2 "2008-09-22T16:28:37Z")

</div>

You’re better off just writing the JavaScript code yourself. Radiant’s  
tag definitions live in the model layer (essentially) and don’t have  
access to the ActionView helpers. That said, you might be able to do  
something like this:

tag ‘myAjaxTag’ do |tag|  
helper = ActionView::Base.new  
helper.send :instance\_variable\_set, “@request”,  
tag.globals.page.request  
helper.link\_to\_remote ‘A’, :url =\> {:action =\> ‘ajaxtest’, :controller  
=\> ‘mycontroller’ }  
end

However, that’s a lot of work just to create a link with an Ajax  
callback. It would be better practice to create a plain link and then  
apply the Ajax callback unobtrusively. LowPro’s Remote.Link works well  
for that. Something like this:

## In your JS

Event.addBehavior({  
‘a.remote’: Remote.Link  
});

## In your HTML

[A](https://www.ruby-forum.com/ajaxtest)

Sean

---

<div class="post-metadata">

**Author:** ![pascal\_n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9c0ed/32.png) [@pascal\_n](https://www.ruby-forum.com/u/pascal_n)\
**Post date:** [September 23, 2008, 1:36pm UTC](https://www.ruby-forum.com/t/ajax-with-radius-tag-in-frontend/149220/3 "2008-09-23T13:36:14Z")

</div>

Hi Sean

Thx a lot for your hints. I try it out.

Pascal
