Javascript rendered in ajax call not working

0 views
Skip to first unread message

drip

unread,
May 5, 2009, 9:29:11 PM5/5/09
to Orlando Ruby Users Group Discussion
Hello all, I'm Jove, and I'm new to the orug. Worked as a developer
some years ago, got out of it for a long time. Just got back into it
with my first contract for ruby development.

I have a number of partials that render correctly in normal usage. The
partial has a snippet of Javascript in it. However, any time the
partial is called as part of an ajax request, ruby/rails seems to
strip the Javascript out of it. I'm not using jquery or anything to
generate the Jjavascript, it is simply a blob of text in the middle of
my source. I've put debugging messages on either side of the blob,
they show up just fine. Only whats inside the <script></script>tags
gets stripped.

Any Ideas? Thanks

Jove Malcolm


Greg Pederson

unread,
May 6, 2009, 12:32:26 PM5/6/09
to orug-di...@googlegroups.com
Hi Jove,
Is your partial only code inside <script></script>?  Does the code not render at all?  Or does it render as plain text? Maybe you can post your partial call and your partial code on pastie.org and send the link.

Greg
--
Greg Pederson
Founder and Technical Director

Nsight Development, LLC.
www.NsightDevelopment.com

Gr...@NsightDevelopment.com
407-641-0327

Quis custodiet ipsos custodes

Greg.P...@gmail.com

Mike Pence

unread,
May 6, 2009, 12:45:29 PM5/6/09
to orug-di...@googlegroups.com
You have to set the content type for the reply to be javascript.

On Tue, May 5, 2009 at 9:29 PM, drip <dr...@dripspeed.com> wrote:
>

drip

unread,
May 6, 2009, 6:55:33 PM5/6/09
to Orlando Ruby Users Group Discussion
I found a way to force it to render a .js.rjs partial, making it at
least send the code to the client. Now my problem is it keeps sending
it as plain text rather than text/javascript, and everything I've
tried doesn't correct that. I tried pulling it as a new ajax call in
an onsubmit, but that doesn't seem to execute the code properly.

I'm trying to make ActiveResource, attachment_fu and mod_upload_status
(for apache) work together nicely. Learning lots about ruby digging
through other people's code.

Jove

PS I'm going to drive down from Gainesville to Orlando for the
Hardware day. Pretty sure everyone will make it worth the drive!
> G...@NsightDevelopment.com
> 407-641-0327
>
> Quis custodiet ipsos custodes
>
> Greg.Peder...@gmail.com

drip

unread,
May 7, 2009, 6:09:57 PM5/7/09
to Orlando Ruby Users Group Discussion
I figured out a work around. I was able to modify the javascript I
needed to be more modular, and loaded it in the head with the rest of
my .js files. I was then able to modify my ajax call to run the new
function, passing a number of parameters, but it's working!
Reply all
Reply to author
Forward
0 new messages