# RJS/Tracking Controller through Radiant Extension?

**URL:** <https://www.ruby-forum.com/t/rjs-tracking-controller-through-radiant-extension/103951>\
**Category:** Radiant CMS\
**Created:** [May 11, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/rjs-tracking-controller-through-radiant-extension/103951 "2007-05-11T21:48:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeconStudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aca169/32.png) [@DeconStudio](https://www.ruby-forum.com/u/DeconStudio)\
**Post date:** [May 11, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/rjs-tracking-controller-through-radiant-extension/103951/1 "2007-05-11T21:48:22Z")

</div>

Hi All  
First post to the list, I have a question about extensions and adding  
RJS  
features to a Radiant site.

What I would like to be able to do is call an RJS action on a click of  
certain buttons of a page, which would then log into a database that the  
action is clicked and use RJS to dynamically update the page to replace  
the  
div with the botton with a new piece of content, like a contact form. I  
would be using RJS to provide the nice ajax type effects for smoothly  
updating the page and replacing certain parts with new elements.

Is this something that would be done through extensions? Is it possible  
to  
use RJS with Radiant and add a little AJAX love to it?

thanks!  
Michael Andrew  
[SEOG.net](http://SEOG.net)

---

<div class="post-metadata">

**Author:** ![DeconStudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aca169/32.png) [@DeconStudio](https://www.ruby-forum.com/u/DeconStudio)\
**Post date:** [May 11, 2007, 10:10pm UTC](https://www.ruby-forum.com/t/rjs-tracking-controller-through-radiant-extension/103951/2 "2007-05-11T22:10:25Z")

</div>

Heh, I get to use this same example twice in 5 minutes. 🙂

[http://pastie.caboo.se/60860](http://pastie.caboo.se/60860)

–  
Building an e-commerce site with Rails?  
[http://agilewebdevelopment.com/rails-ecommerce](http://agilewebdevelopment.com/rails-ecommerce)

Meet up at RailsConf:  
[http://railsconf2007.conferencemeetup.com/](http://railsconf2007.conferencemeetup.com/)

---

<div class="post-metadata">

**Author:** ![DeconStudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aca169/32.png) [@DeconStudio](https://www.ruby-forum.com/u/DeconStudio)\
**Post date:** [May 12, 2007, 12:22am UTC](https://www.ruby-forum.com/t/rjs-tracking-controller-through-radiant-extension/103951/3 "2007-05-12T00:22:35Z")

</div>

I’m a rails newb so excuse this if it seems silly to all the experienced  
folks out there.

But in the example that you posted with the SamplePage class – I am  
assuming I would make my own class as a subclass of page and then follow  
the  
instructions for loading it as an extension from the Radiant docs.

Then calling it in the theme with something like this:

\<% form\_remote\_tag :url =\> { :action =\> :SamplePage, :id =\> form\_button  
} do  
%\>  
\<%= submit\_tag “Email Me” %\>  
\<% end %\>

But replacing the action with whatever Class I made, like FormDisplay  
let’s  
say.

And then change the appropriate Element.update calls to whatever RJS  
actions  
I want to take on the element within the Body of the document, which  
would  
be the HTML I have loaded into that page’s body section through  
Radiant’s  
backend administration.

Am I close? 🙂

thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![DeconStudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aca169/32.png) [@DeconStudio](https://www.ruby-forum.com/u/DeconStudio)\
**Post date:** [May 12, 2007, 12:39am UTC](https://www.ruby-forum.com/t/rjs-tracking-controller-through-radiant-extension/103951/4 "2007-05-12T00:39:37Z")

</div>

DeconStudio wrote:

> But in the example that you posted with the SamplePage class – I am  
> assuming I would make my own class as a subclass of page and then follow the  
> instructions for loading it as an extension from the Radiant docs.

Creating that class and the extension is a step in the right  
direction. After that you can create pages that have the type of your  
new class.

> Then calling it in the theme with something like this:
> 
> \<% form\_remote\_tag :url =\> { :action =\> :SamplePage, :id =\> form\_button } do  
> %\>  
> \<%= submit\_tag “Email Me” %\>  
> \<% end %\>

Pages don’t support ActionView helpers. You will have to convert  
everything to “real” HTML/Javascript.

> But replacing the action with whatever Class I made, like FormDisplay let’s  
> say.

No a URL to a page with the type of your new page class.

> And then change the appropriate Element.update calls to whatever RJS actions  
> I want to take on the element within the Body of the document, which would  
> be the HTML I have loaded into that page’s body section through Radiant’s  
> backend administration.

Hmm, I don’t think you can use ActionController functions such as  
render in a Page’s process method. So no RJS, again pure Javascript  
only, as in the example.

> Am I close? 🙂

Just a little.

You are probably better off writing a separate controller that handles  
your requests instead of creating a derived page class.

Cheers,  
Oliver
