I am trying to use RJS as shown in this tutorial :
http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates
However it does not seem to work. I am not getting any excpetions in
the logs. Here is what the logs say :
Parameters: {"action"=>"add",
"controller"=>"homepage"}
Rendering homepage/add
The homepage/add is named add.rjs
I know that this file is being accessed, if I put some incorrect code
there it complains in the logs.
I am not sure that "rake rails:update" (in the application folder)
works
correctly for me. This is because I have updated to the latest version
of rails and then I copied conf/boot.rb to /tmp folder and did this
command
rake rails:update:configs
According to this post
http://weblog.rubyonrails.org/articles/2006/04/09/rails-1-1-2-tiny-fix-for-gems-dependenciesI
It should update your boot.rb. But I did a diff and the files are the
same. This could mean that I have not got the correct js files to allow
RJS to work? Is there a way of checking if I have the correect JS files
that support RJS ?
Here is ths code :
homepage/add.rjs :
page.replace_html ''header'',''RJS Template Test
Complete!''
in homepage/list
<h1 id=''header''>RJS Template Test</h1>
<%= link_to_remote("Change Title", :url =>{ :action =>
''add'' }) %>
in the homepage controller
def add
end
By the way I am importing the javascripts like this :
<%= javascript_include_tag :defaults %>
I would appreciate any help, as I have been struggling all morning.
Thanks in advance.
Hamza
--
Posted via http://www.ruby-forum.com/.
try adding a :complete=>''alert(response.responseText)'' to your function call. This should pop up the RJS output and give you more information about why the call failed. On Tuesday, April 11, 2006, at 3:41 PM, Hamza Khan-Cheema wrote:>I am trying to use RJS as shown in this tutorial : > >http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates > >However it does not seem to work. I am not getting any excpetions in >the logs. Here is what the logs say : > >Parameters: {"action"=>"add", "controller"=>"homepage"} >Rendering homepage/add > >The homepage/add is named add.rjs > >I know that this file is being accessed, if I put some incorrect code >there it complains in the logs. > >I am not sure that "rake rails:update" (in the application folder) works >correctly for me. This is because I have updated to the latest version >of rails and then I copied conf/boot.rb to /tmp folder and did this >command > >rake rails:update:configs > >According to this post > >http://weblog.rubyonrails.org/articles/2006/04/09/ >rails-1-1-2-tiny-fix-for-gems-dependenciesI > >It should update your boot.rb. But I did a diff and the files are the >same. This could mean that I have not got the correct js files to allow >RJS to work? Is there a way of checking if I have the correect JS files >that support RJS ? > >Here is ths code : > >homepage/add.rjs : > >page.replace_html ''header'',''RJS Template Test Complete!'' > >in homepage/list ><h1 id=''header''>RJS Template Test</h1> > <%= link_to_remote("Change Title", :url =>{ :action => ''add'' }) %> > >in the homepage controller > >def add >end > >By the way I am importing the javascripts like this : > ><%= javascript_include_tag :defaults %> > > >I would appreciate any help, as I have been struggling all morning. > >Thanks in advance. > >Hamza > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails_Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Keven,
Thanks fo the reply. I have added an alert to the link. This is what
it is now:
<%= link_to_remote("Change Title", :url =>{:action => :add },
:complete
=> "alert(request.responseText)") %>
I do get an alert. This is what it says :
Element.update("header","RJS Template Test Complete!"); Load
Suite
dispatch etc.
It still does not update the title (with a id of ''header'').
But it does
seem to be actioning the correct code. Does anyone have any suggestions
?
I even tried to put a doctype for the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"> etc.
I have also tried ''page.remove'' and
''page.insert_html'' But nothing
seems to work.
Thanks.
Hamza
Kevin Olbrich wrote:> try adding a :complete=>''alert(response.responseText)''
to your function
> call.
>
> This should pop up the RJS output and give you more information about
> why the call failed.
>
> On Tuesday, April 11, 2006, at 3:41 PM, Hamza Khan-Cheema wrote:
>>The homepage/add is named add.rjs
>>
>>Here is ths code :
>>
>>Thanks in advance.
>>
>>Hamza
>>
>>--
>>Posted via http://www.ruby-forum.com/.
>>_______________________________________________
>>Rails mailing list
>>Rails@lists.rubyonrails.org
>>http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
> _Kevin
--
Posted via http://www.ruby-forum.com/.
On Tue, 11 Apr 2006, Hamza Khan-Cheema wrote:> Keven, > > Thanks fo the reply. I have added an alert to the link. This is what > it is now: > > <%= link_to_remote("Change Title", :url =>{:action => :add }, :complete > => "alert(request.responseText)") %> > > I do get an alert. This is what it says : > > Element.update("header","RJS Template Test Complete!"); Load Suite > dispatch etc. > > It still does not update the title (with a id of ''header''). But it does > seem to be actioning the correct code. Does anyone have any suggestions > ?I had a similar problem when I was setting the Content-Type header to be "text/html" for all actions. RJS needs to be rendered with a different Content-Type (application/javascript or something, can''t remember right now). Check to see if you''re doing something like that, maybe using a :before_filter or similar thing to set it - when I did it, it was giving the exact same symptoms you''re describing. --Wade
Wade, I am not seting the content type to HTML by default. However I did have the following in the file : <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> I took this out but it had no effect. I have also added this to the add method : def add @headers["Content-Type"] = "text/javascript" end But all this has no effect. However what I am doing is, I am using UTF characaters. I am not sure this would effect anything ? I will try and create an empty rails app to see if I am getting the same error. Other then that I am still stuck. By the way, Is that add method correct ? Can i change the header like that when making a RJS request ? Thanks Hamza H. Wade Minter wrote:> On Tue, 11 Apr 2006, Hamza Khan-Cheema wrote: > >> Element.update("header","RJS Template Test Complete!"); Load Suite >> dispatch etc. >> >> It still does not update the title (with a id of ''header''). But it does >> seem to be actioning the correct code. Does anyone have any suggestions >> ? > > I had a similar problem when I was setting the Content-Type header to be > "text/html" for all actions. RJS needs to be rendered with a different > Content-Type (application/javascript or something, can''t remember right > now). Check to see if you''re doing something like that, maybe using a > :before_filter or similar thing to set it - when I did it, it was giving > the exact same symptoms you''re describing. > > --Wade-- Posted via http://www.ruby-forum.com/.
Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 250 bytes Desc: OpenPGP digital signature Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/c796958e/signature.bin
Hamza, What version is your Prototype library? Take a look inside public/javascripts/prototype.js to find out. On 4/11/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote:> Keven, > > Thanks fo the reply. I have added an alert to the link. This is what > it is now: > > <%= link_to_remote("Change Title", :url =>{:action => :add }, :complete > => "alert(request.responseText)") %> > > I do get an alert. This is what it says : > > Element.update("header","RJS Template Test Complete!"); Load Suite > dispatch etc. > > It still does not update the title (with a id of ''header''). But it does > seem to be actioning the correct code. Does anyone have any suggestions > ? > > I even tried to put a doctype for the page. > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> etc. > > I have also tried ''page.remove'' and ''page.insert_html'' But nothing > seems to work. > > Thanks. > > Hamza > > > Kevin Olbrich wrote: > > try adding a :complete=>''alert(response.responseText)'' to your function > > call. > > > > This should pop up the RJS output and give you more information about > > why the call failed. > > > > On Tuesday, April 11, 2006, at 3:41 PM, Hamza Khan-Cheema wrote: > >>The homepage/add is named add.rjs > >> > >>Here is ths code : > >> > >>Thanks in advance. > >> > >>Hamza > >> > >>-- > >>Posted via http://www.ruby-forum.com/. > >>_______________________________________________ > >>Rails mailing list > >>Rails@lists.rubyonrails.org > >>http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _Kevin > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cody Fauser http://www.codyfauser.com
Cody, The version of my Prototype js is : 1.5.0_rc0 Is this the correct version ? Thanks Hamza Cody Fauser wrote:> Hamza, > > What version is your Prototype library? Take a look inside > public/javascripts/prototype.js to find out. > > On 4/11/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote: >> Element.update("header","RJS Template Test Complete!"); Load Suite >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> etc. >> > try adding a :complete=>''alert(response.responseText)'' to your function >> >>Thanks in advance. >> > >> > _Kevin >> >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Cody Fauser > http://www.codyfauser.com-- Posted via http://www.ruby-forum.com/.
Yeah, that is correct. Try making your rjs template only this:
page.alert(''test'') and see if you get a popup.
On 4/12/06, Hamza Khan-Cheema <hamzakc@gmail.com>
wrote:> Cody,
>
> The version of my Prototype js is : 1.5.0_rc0
>
> Is this the correct version ?
>
> Thanks
>
> Hamza
>
> Cody Fauser wrote:
> > Hamza,
> >
> > What version is your Prototype library? Take a look inside
> > public/javascripts/prototype.js to find out.
> >
> > On 4/11/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote:
> >> Element.update("header","RJS Template Test
Complete!"); Load Suite
> >> <html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"> etc.
> >> > try adding a
:complete=>''alert(response.responseText)'' to your function
> >> >>Thanks in advance.
> >> >
> >> > _Kevin
> >>
> >>
> >> --
> >> Posted via http://www.ruby-forum.com/.
> >> _______________________________________________
> >> Rails mailing list
> >> Rails@lists.rubyonrails.org
> >> http://lists.rubyonrails.org/mailman/listinfo/rails
> >>
> >
> >
> > --
> > Cody Fauser
> > http://www.codyfauser.com
>
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Cody Fauser
http://www.codyfauser.com
Needless to say but a precaution; when you make rjs template for an action, be sure you don''t have any other template view (rhtml or rxml) for the same action. On 4/12/06, Cody Fauser <codyfauser@gmail.com> wrote:> > Yeah, that is correct. Try making your rjs template only this: > page.alert(''test'') and see if you get a popup. > > On 4/12/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote: > > Cody, > > > > The version of my Prototype js is : 1.5.0_rc0 > > > > Is this the correct version ? > > > > Thanks > > > > Hamza > > > > Cody Fauser wrote: > > > Hamza, > > > > > > What version is your Prototype library? Take a look inside > > > public/javascripts/prototype.js to find out. > > > > > > On 4/11/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote: > > >> Element.update("header","RJS Template Test Complete!"); Load Suite > > >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> > etc. > > >> > try adding a :complete=>''alert(response.responseText)'' to your > function > > >> >>Thanks in advance. > > >> > > > >> > _Kevin > > >> > > >> > > >> -- > > >> Posted via http://www.ruby-forum.com/. > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails@lists.rubyonrails.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > > > > > > > -- > > > Cody Fauser > > > http://www.codyfauser.com > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Cody Fauser > http://www.codyfauser.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060413/976d28af/attachment.html
Cody, Even that does not display an alert box. I have tried multiple things in the add.rjs file Rizwan, I do not have any other view named add. Hamza Cody Fauser wrote:> Yeah, that is correct. Try making your rjs template only this: > page.alert(''test'') and see if you get a popup. > > On 4/12/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote: >> Cody Fauser wrote: >> >> > >> > >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Cody Fauser > http://www.codyfauser.com-- Posted via http://www.ruby-forum.com/.
Can you post the source from your browser and your controller code? On 4/13/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote:> Cody, > > Even that does not display an alert box. I have tried multiple things > in the add.rjs file > > Rizwan, > > I do not have any other view named add. > > Hamza > > Cody Fauser wrote: > > Yeah, that is correct. Try making your rjs template only this: > > page.alert(''test'') and see if you get a popup. > > > > On 4/12/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote: > >> Cody Fauser wrote: > >> >> > > >> > > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > > -- > > Cody Fauser > > http://www.codyfauser.com > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cody Fauser http://www.codyfauser.com
Hi, I have finaly figured out why RJS was not working :) My rails setup was going through Apache2 using fastcgi. I went through this tutorial : http://fo64.com/articles/2005/10/20/rails-on-breezy However, when I turned off Apache and went through WEBrick AJAX started to worked :). This obvsioully meant that Apache was not sending the AJAX requsts to Rails. Thank you to everyone who helped. I just need to figure out how to get Apache working now :) Hamza Cody Fauser wrote:> Can you post the source from your browser and your controller code? > > On 4/13/06, Hamza Khan-Cheema <hamzakc@gmail.com> wrote: >> >> >> >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Cody Fauser > http://www.codyfauser.com-- Posted via http://www.ruby-forum.com/.