I''ve been attempting to add a simple rjs ''delete'' method to my project. However, no matter what I try, it simply doesn''t work. Even the easy, easy stuff seems broken. (Yes, <%= javascript_include_tag :defaults %> is being included in the template.) For example, from: http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates VIEW: <h1 id=''header''>RJS Template Test</h1> <ul id=''list''> <li>Dog</li> <li>Cat</li> <li>Mouse</li> </ul> <%= link_to_remote("Add a fox", :url =>{ :action => :add }) %> CONTROLLER: def add end RJS: page.insert_html :bottom, ''list'', content_tag("li", "Fox") page.visual_effect :highlight, ''list'', :duration => 3 page.replace_html ''header'', ''RJS Template Test Complete!'' results in nothing. Any insights? - josh _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Are you running on Edge rails or have the RJS plugin installed? It''s not built into Rails yet. -PJ http://pjhyett.com On 12/25/05, Joshua Paul <joshpaul-ee4meeAH724@public.gmane.org> wrote:> I''ve been attempting to add a simple rjs ''delete'' method to my > project. However, no matter what I try, it simply doesn''t work. Even > the easy, easy stuff seems broken. (Yes, <%> javascript_include_tag :defaults %> is being included in the template.) > > For example, from: > http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates > > VIEW: > <h1 id=''header''>RJS Template Test</h1> > <ul id=''list''> > <li>Dog</li> > <li>Cat</li> > <li>Mouse</li> > </ul> > <%= link_to_remote("Add a fox", :url =>{ :action => :add }) %> > > CONTROLLER: > def add > end > > RJS: > page.insert_html :bottom, ''list'', content_tag("li", "Fox") > page.visual_effect :highlight, ''list'', :duration => 3 > page.replace_html ''header'', ''RJS Template Test Complete!'' > > results in nothing. > > Any insights? > > - josh > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >
On Sun, Dec 25, 2005 at 11:10:24AM -0800, Joshua Paul wrote:> I''ve been attempting to add a simple rjs ''delete'' method to my > project. However, no matter what I try, it simply doesn''t work. Even > the easy, easy stuff seems broken. (Yes, <%= > javascript_include_tag :defaults %> is being included in the template.) > > For example, from: > http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates > > VIEW: > <h1 id=''header''>RJS Template Test</h1> > <ul id=''list''> > <li>Dog</li> > <li>Cat</li> > <li>Mouse</li> > </ul> > <%= link_to_remote("Add a fox", :url =>{ :action => :add }) %> > > CONTROLLER: > def add > end > > RJS: > page.insert_html :bottom, ''list'', content_tag("li", "Fox") > page.visual_effect :highlight, ''list'', :duration => 3 > page.replace_html ''header'', ''RJS Template Test Complete!'' > > results in nothing. > > Any insights?Are you using codyfauser''s rjs plugin with rails 1.0 or the code in edge rails? marcel -- Marcel Molina Jr. <marcel-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org>
Edge. I actually started with my own code (based on BNR bootcamp code). I then came across the http://www.codyfauser.com/articles/2005/11/20/ rails-rjs-templates page. For my own code I have: *** CONTROLLER: before_filter :fetch_viewing, :only => [:show, :destroy] def destroy @viewing.destroy end protected # Fetch a viewing, based on incoming params[:id] def fetch_viewing @viewing = Viewing.find(params[:id]) end HELPER: def viewing_dom_id(viewing) "viewing-#{viewing.id}" end VIEW: <%= link_to_remote ''Destroy'', :url => destroy_viewings_url(:id => viewing), :failure =>"alert(''Unkown error '' + request.status)" %> RJS: page.visual_effect :blind_up, viewing_dom_id(@viewing) page.visual_effect :fade, viewing_dom_id(@viewing) ROUTES: map.destroy_viewings ''destroy/:id'', :controller => ''viewings'', :action => ''destroy'' Generated HTML: <div class="viewing" id="viewing-4"> <h2>User: Test User</h2> <h3>Time in: Sun Dec 25 10:52:17 PST 2005</h3> <h3>Time out: Sun Dec 25 10:59:21 PST 2005</h3> <h3>Quality: 10</h3> <p> <div> <a href="/viewings/show/4">Show</a> | <a href="#" onclick="new Ajax.Request(''http://localhost:3000/destroy/ 4'', {asynchronous:true, evalScripts:true, onFailure:function(request) {alert(''Unkown error '' + request.status)}}); return false;">Destroy</a> </div> </p> </div> *** When I use it, the object is destroyed, however the js effect doesn''t occur. I get a 500 error. Thanks! - josh On Dec 25, 2005, at 11:54 AM, rails-request-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org wrote:> Are you using codyfauser''s rjs plugin with rails 1.0 or the code in > edge > rails? > > marcel_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 12/25/05, Joshua Paul <joshpaul-ee4meeAH724@public.gmane.org> wrote:> Edge. > > I actually started with my own code (based on BNR bootcamp code). I > then came across the http://www.codyfauser.com/articles/2005/11/20/ > rails-rjs-templates page.Have you updated your javascript files (rake update_javascript) ? An older version of prototype didn''t execute the RJS automatically and required an explicit complete callback. The other issue I''ve had is the ajax action raising exceptions. Check your logs for any, or use a global ajax responder (http://rails.techno-weenie.net/tip/2005/12/20/debugging_your_rjs_calls) to see the returned code. I''ve had instances where the code redirected because of a bad verify call and would send the HTML of the page it redirected to, for example. -- rick http://techno-weenie.net
Got it...never mind...a simple @ sign fixed the problem. On Dec 25, 2005, at 12:19 PM, Joshua Paul wrote:> Edge. > > I actually started with my own code (based on BNR bootcamp code). I > then came across the http://www.codyfauser.com/articles/2005/11/20/ > rails-rjs-templates page. > > For my own code I have: > *** > CONTROLLER: > before_filter :fetch_viewing, :only => [:show, :destroy] > > def destroy > @viewing.destroy > end > > protected > # Fetch a viewing, based on incoming params[:id] > def fetch_viewing > @viewing = Viewing.find(params[:id]) > end > > HELPER: > def viewing_dom_id(viewing) > "viewing-#{viewing.id}" > end > > VIEW: > <%= link_to_remote ''Destroy'', :url => destroy_viewings_url(:id => > viewing), :failure =>"alert(''Unkown error '' + request.status)" %> > > RJS: > page.visual_effect :blind_up, viewing_dom_id(@viewing) > page.visual_effect :fade, viewing_dom_id(@viewing) > > ROUTES: > map.destroy_viewings ''destroy/:id'', :controller => > ''viewings'', :action => ''destroy'' > > Generated HTML: > <div class="viewing" id="viewing-4"> > <h2>User: Test User</h2> > <h3>Time in: Sun Dec 25 10:52:17 PST 2005</h3> > <h3>Time out: Sun Dec 25 10:59:21 PST 2005</h3> > <h3>Quality: 10</h3> > <p> > <div> > <a href="/viewings/show/4">Show</a> | > <a href="#" onclick="new Ajax.Request(''http://localhost:3000/ > destroy/4'', {asynchronous:true, evalScripts:true, onFailure:function > (request){alert(''Unkown error '' + request.status)}}); return > false;">Destroy</a> > </div> > </p> > </div> > *** > > When I use it, the object is destroyed, however the js effect > doesn''t occur. I get a 500 error. > > Thanks! > > - josh > > On Dec 25, 2005, at 11:54 AM, rails-request-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > wrote: > >> Are you using codyfauser''s rjs plugin with rails 1.0 or the code >> in edge >> rails? >> >> marcel