# Javascript without rjs

**URL:** <https://www.ruby-forum.com/t/javascript-without-rjs/135544>\
**Category:** Rails\
**Created:** [April 23, 2008, 12:41am UTC](https://www.ruby-forum.com/t/javascript-without-rjs/135544 "2008-04-23T00:41:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 23, 2008, 12:41am UTC](https://www.ruby-forum.com/t/javascript-without-rjs/135544/1 "2008-04-23T00:41:59Z")

</div>

I’ve been googling for ages, please help.

I don’t want to use rjs and the view helpers for prototype, I just  
want to render javascript (jquery), and no I don’t want to use jrails  
either as this just partially mimics those same helpers.

Can’t I just render a some\_action.js file?

Rails 2.0.2

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 23, 2008, 1:58am UTC](https://www.ruby-forum.com/t/javascript-without-rjs/135544/2 "2008-04-23T01:58:42Z")

</div>

> Can’t I just render a some\_action.js file?

Not entirely sure if that’s what you mean (it’s way past my bedtime :),  
but I use a JavascriptsController. This way, a request to  
‘/javascripts/some\_action.js’ will be either satisfied by serving a  
static file from public/javascripts, or if no such file exists, by a  
controller method of that name from my JavaScriptsController, which  
renders a nice dynamic show\_action.js.erb view.

Hope this helps,  
Jan

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 23, 2008, 11:47am UTC](https://www.ruby-forum.com/t/javascript-without-rjs/135544/3 "2008-04-23T11:47:52Z")

</div>

I don’t suppose you could give me an example. Promise I’ll write it up  
for the group.

Thanks.

On Apr 23, 12:58 am, Jan F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 24, 2008, 8:50pm UTC](https://www.ruby-forum.com/t/javascript-without-rjs/135544/4 "2008-04-24T20:50:58Z")

</div>

Yes, I want to create raw (at least not using helpers) dynamically, so  
I could use e.g. jquery.

On Apr 23, 11:24 am, Jan F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 23, 2008, 12:24pm UTC](https://www.ruby-forum.com/t/javascript-without-rjs/135544/5 "2008-04-23T12:24:31Z")

</div>

I’m well rested now, but I am still not sure what you’re trying to  
achieve. You are not bound to use any helpers at all; you are free to  
write JS directly into your views the usual way if that is what you  
prefer.

If you want to include an external script into a view, just put it into  
the public/javascripts folder of your application and include it either  
manually or through the javascript\_include\_tag helper.

The JavascriptsController only makes sense if you have the need to  
create JS dynamically, say, with ERb.

I’d be happy to provide examples, I just need to know which direction  
you’re heading here.

Cheers,  
Jan
