Hi, I''m trying to work with RJS and folowed Cody Fauser''s tutorial (http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates) I''ve started by creating a new rails applications and executing rake freeze_edge rake rails:update:javascripts rake rails:update:scripts After that I''ve created a controller: class DtestController < ApplicationController def add end end Created the files add.rhtml and add.rjs in views/dtest/ ,and dtest.rhtml in views/layouts. I''ve started my server and called my add action and nothing happends . Can anyone explain me what I did wrong ? My prototype version is 1.5.0_pre0 Thanks, Ovidiu
Hi, I didn''t try RJS templates yet, but from what I understand if there are both a .rhtml and a .rjs template, then rails picks up the .rhtml one. Waht you''ll want to do in your add action is change the view produced by a _different_ action. HTH, Michael Ovidiu EFTIMIE wrote:> Hi, > I''m trying to work with RJS and folowed Cody Fauser''s tutorial > (http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates) > I''ve started by creating a new rails applications and executing > rake freeze_edge > rake rails:update:javascripts > rake rails:update:scripts > > After that I''ve created a controller: > class DtestController < ApplicationController > def add > end > end > > Created the files add.rhtml and add.rjs in views/dtest/ ,and > dtest.rhtml in views/layouts. > I''ve started my server and called my add action and nothing happends . > Can anyone explain me what I did wrong ? > My prototype version is 1.5.0_pre0 > > Thanks, > Ovidiu
> > Created the files add.rhtml and add.rjs in views/dtest/ ,and > dtest.rhtml in views/layouts. >The tutorial says: Rails now looks for templates with an extension of .rjs, in addition to .rhtml and .rxml, so create a view named add.rjs for your controller and add the following code to it: bla, bla.... It doesn''t say anything about create a .rhtml view. It only says that last version of Rails search for templates .rjs too. I haven''t used RJS but I think you only need .rjs view to follow the tutorial. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060314/2a08619a/attachment.html
What I understand is that the .rjs page (which must have the same name with the .rhtml page) is used -- after -- the page is rendered>From the tutorial>>>Unlike conventional templates which are used to render the results of an action, these templates generate instructions on how to modify an already rendered page. This makes it easy to modify multiple elements on your page in one declarative Ajax response. Actions with these templates are called in the background with Ajax and make updates to the page where the request originated from.>>>Ovidiu On 3/14/06, Eduardo Y??ez Parareda <eduardo.yanez@gmail.com> wrote:> > > Created the files add.rhtml and add.rjs in views/dtest/ ,and > > dtest.rhtml in views/layouts. > > > > The tutorial says: > > Rails now looks for templates with an extension of .rjs, in addition to > .rhtml and .rxml, so create a view named add.rjs for your controller and add > the following code to it: bla, bla.... > > It doesn''t say anything about create a .rhtml view. It only says that last > version of Rails search for templates .rjs too. > I haven''t used RJS but I think you only need .rjs view to follow the > tutorial. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Ovidiu EFTIMIE wrote:> What I understand is that the .rjs page (which must have the same name > with the .rhtml page) is used -- after -- the page is renderedNo, it must not have the same name. There could potientially be several actions wanting to change the rendered page in some way, so they have to be distinct from the action that originally rendered the page. Give it a try and make different actions for rendering and changing the page...
Ovidiu EFTIMIE wrote:> What I understand is that the .rjs page (which must have the same name > with the .rhtml page) is used -- after -- the page is renderedNope, it works on an existing page. so you call /controller/show/1, that triggers views/controller/show.rhtml to display stuff. You then issue an ajax call to /controller/add_list_item/1, that will trigger /views/controller/add_to_list_item.rjs which returns javascript to modify the existing (show) page. Each action renders only one template, some are (r)html, some are (r)js. Is this any clearer ? A. -- Posted via http://www.ruby-forum.com/.
I''ve added an index action class DtestController < ApplicationController def index end def add end end and renamed the add.rhtml to index.rhtml. Now it works well. Acctually at the beggining id didn''t work at all . I''ve deleted the ruby session from %TEMP% and then is started to work Thanx, Ovidiu On 3/14/06, Michael Kaiser <hckygyg@yahoo.de> wrote:> Ovidiu EFTIMIE wrote: > > What I understand is that the .rjs page (which must have the same name > > with the .rhtml page) is used -- after -- the page is rendered > > No, it must not have the same name. There could potientially be several > actions wanting to change the rendered page in some way, so they have to > be distinct from the action that originally rendered the page. Give it a > try and make different actions for rendering and changing the page... > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thanx Alan. Much clearer:) On 3/14/06, Ovidiu EFTIMIE <eovidiu@gmail.com> wrote:> I''ve added an index action > class DtestController < ApplicationController > def index > end > def add > end > end > and renamed the add.rhtml to index.rhtml. > Now it works well. > Acctually at the beggining id didn''t work at all . I''ve deleted the > ruby session from %TEMP% and then is started to work > > Thanx, > Ovidiu > > On 3/14/06, Michael Kaiser <hckygyg@yahoo.de> wrote: > > Ovidiu EFTIMIE wrote: > > > What I understand is that the .rjs page (which must have the same name > > > with the .rhtml page) is used -- after -- the page is rendered > > > > No, it must not have the same name. There could potientially be several > > actions wanting to change the rendered page in some way, so they have to > > be distinct from the action that originally rendered the page. Give it a > > try and make different actions for rendering and changing the page... > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >