Ovidiu EFTIMIE
2006-Mar-28 22:52 UTC
[Rails] RJS call from controller issues javascript that doesn''t get evaluated by browser
Hi, I''m on Rails 1.1 and I have a problem wit RJS In my cotroller i have ==>>> def show @contact = Contact.find(params[:id]) render :update do |page| page[:contactInfo].replace_html :partial=>"contactInfo" end end <<<== And my contactInfo partial looks like this and it''s placed inside a div element ==>>> <table> <tr> <td><b><%=h @contact.first_name%></b> <%=h @contact.last_name%></td> </tr> <tr> <td><%=h @contact.address.address%><td> </tr> <tr> <td>Tel : <%h= @contact.address.phone%> Fax : <%h= @contact.address.fax%> E-mail : <%h= @contact.address.email%> <td> </tr> </table> <<<= The thing is that my show method gets called and it returns a java script call $("contactInfo").update("<table>\n <tr>\n <td><b>aaa</b> aaa</td>\n </tr>\n <tr>\n <td>aaa<td>\n </tr>\n <tr>\n <td>Tel : \n Fax : \n E-mail : \n <td>\n </tr>\n \n</table> "); Can anyone tell me how to get my div updated ? Thanx, Ovidiu
Bruno Celeste
2006-Mar-28 23:07 UTC
[Rails] RJS call from controller issues javascript that doesn''t get evaluated by browser
You have not specified the id element to update in replace_html method (which expects an id). You should replace this line that way: page.replace_html "contactInfo", :partial => "contactInfo" On 3/29/06, Ovidiu EFTIMIE <eovidiu@gmail.com> wrote:> Hi, > I''m on Rails 1.1 and I have a problem wit RJS > In my cotroller i have > ==>>> > def show > @contact = Contact.find(params[:id]) > render :update do |page| > page[:contactInfo].replace_html :partial=>"contactInfo" > end > end > <<<==> > And my contactInfo partial looks like this and it''s placed inside a div element > ==>>> > <table> > <tr> > <td><b><%=h @contact.first_name%></b> <%=h > @contact.last_name%></td> > </tr> > <tr> > <td><%=h @contact.address.address%><td> > </tr> > <tr> > <td>Tel : <%h= @contact.address.phone%> > Fax : <%h= @contact.address.fax%> > E-mail : <%h= @contact.address.email%> > <td> > </tr> > </table> > <<<=> > The thing is that my show method gets called and it returns a java script call > $("contactInfo").update("<table>\n <tr>\n > <td><b>aaa</b> aaa</td>\n </tr>\n <tr>\n > <td>aaa<td>\n </tr>\n <tr>\n <td>Tel : \n > Fax : \n E-mail : \n <td>\n </tr>\n > \n</table> "); > > Can anyone tell me how to get my div updated ? > > Thanx, > Ovidiu > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ovidiu EFTIMIE
2006-Mar-29 06:21 UTC
[Rails] RJS call from controller issues javascript that doesn''t get evaluated by browser
Actually I have done as you suggested and the result is the same. page[:contactInfo].replace_html :partial=>"contactInfo" is also valid. On 3/29/06, Bruno Celeste <bruno.celeste@gmail.com> wrote:> You have not specified the id element to update in replace_html method > (which expects an id). > You should replace this line that way: > > page.replace_html "contactInfo", :partial => "contactInfo" > > On 3/29/06, Ovidiu EFTIMIE <eovidiu@gmail.com> wrote: > > Hi, > > I''m on Rails 1.1 and I have a problem wit RJS > > In my cotroller i have > > ==>>> > > def show > > @contact = Contact.find(params[:id]) > > render :update do |page| > > page[:contactInfo].replace_html :partial=>"contactInfo" > > end > > end > > <<<==> > > > And my contactInfo partial looks like this and it''s placed inside a div element > > ==>>> > > <table> > > <tr> > > <td><b><%=h @contact.first_name%></b> <%=h > > @contact.last_name%></td> > > </tr> > > <tr> > > <td><%=h @contact.address.address%><td> > > </tr> > > <tr> > > <td>Tel : <%h= @contact.address.phone%> > > Fax : <%h= @contact.address.fax%> > > E-mail : <%h= @contact.address.email%> > > <td> > > </tr> > > </table> > > <<<=> > > > The thing is that my show method gets called and it returns a java script call > > $("contactInfo").update("<table>\n <tr>\n > > <td><b>aaa</b> aaa</td>\n </tr>\n <tr>\n > > <td>aaa<td>\n </tr>\n <tr>\n <td>Tel : \n > > Fax : \n E-mail : \n <td>\n </tr>\n > > \n</table> "); > > > > Can anyone tell me how to get my div updated ? > > > > Thanx, > > Ovidiu > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Cody Fauser
2006-Mar-29 18:07 UTC
[Rails] RJS call from controller issues javascript that doesn''t get evaluated by browser
- Are you changing the Content-Type of the response? It needs to be ''text/javascript'' to be automatically evaluated by Prototype. - Your div has the id ''contactInfo''? - Make sure you aren''t using the :update option in your remote function call. - Did you run ''rake rails:update'' to update your JavaScripts? - Does popping an alert box work? page.alert(''RJS works!'') On 3/29/06, Ovidiu EFTIMIE <eovidiu@gmail.com> wrote:> Actually I have done as you suggested and the result is the same. > page[:contactInfo].replace_html :partial=>"contactInfo" is also valid. > > > On 3/29/06, Bruno Celeste <bruno.celeste@gmail.com> wrote: > > You have not specified the id element to update in replace_html method > > (which expects an id). > > You should replace this line that way: > > > > page.replace_html "contactInfo", :partial => "contactInfo" > > > > On 3/29/06, Ovidiu EFTIMIE <eovidiu@gmail.com> wrote: > > > Hi, > > > I''m on Rails 1.1 and I have a problem wit RJS > > > In my cotroller i have > > > ==>>> > > > def show > > > @contact = Contact.find(params[:id]) > > > render :update do |page| > > > page[:contactInfo].replace_html :partial=>"contactInfo" > > > end > > > end > > > <<<==> > > > > > And my contactInfo partial looks like this and it''s placed inside a div element > > > ==>>> > > > <table> > > > <tr> > > > <td><b><%=h @contact.first_name%></b> <%=h > > > @contact.last_name%></td> > > > </tr> > > > <tr> > > > <td><%=h @contact.address.address%><td> > > > </tr> > > > <tr> > > > <td>Tel : <%h= @contact.address.phone%> > > > Fax : <%h= @contact.address.fax%> > > > E-mail : <%h= @contact.address.email%> > > > <td> > > > </tr> > > > </table> > > > <<<=> > > > > > The thing is that my show method gets called and it returns a java script call > > > $("contactInfo").update("<table>\n <tr>\n > > > <td><b>aaa</b> aaa</td>\n </tr>\n <tr>\n > > > <td>aaa<td>\n </tr>\n <tr>\n <td>Tel : \n > > > Fax : \n E-mail : \n <td>\n </tr>\n > > > \n</table> "); > > > > > > Can anyone tell me how to get my div updated ? > > > > > > Thanx, > > > Ovidiu > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cody Fauser http://www.codyfauser.com
Cody Fauser
2006-Mar-29 18:15 UTC
[Rails] RJS call from controller issues javascript that doesn''t get evaluated by browser
To clarify:> - Are you changing the Content-Type of the response? It needs to be > ''text/javascript'' to be automatically evaluated by Prototype.Make sure you aren''t overwriting the Content-Type. RJS will set it for you automatically. -- Cody Fauser http://www.codyfauser.com
Ovidiu EFTIMIE
2006-Mar-30 21:22 UTC
[Rails] RJS call from controller issues javascript that doesn''t get evaluated by browser
Cody .... you''re the man:). Thanx a lot !!! Actualy I was having tha update option set in my remote function call Now it looks like this <%= remote_function(:complete =>"new Effect.Highlight(''contactInfo'' )", :url => { :action => ''show'',:id=>contact.id}) %>" On 3/29/06, Cody Fauser <codyfauser@gmail.com> wrote:> To clarify: > > > - Are you changing the Content-Type of the response? It needs to be > > ''text/javascript'' to be automatically evaluated by Prototype. > > Make sure you aren''t overwriting the Content-Type. RJS will set it > for you automatically. > > -- > Cody Fauser > http://www.codyfauser.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >