The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Ajax And Non-Ajax

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Amos King

Posts: 78
Nickname: adkron
Registered: Jan, 2007

Amos King is a Web Developer for the US Postal Service and for Ramped Media.
Ajax And Non-Ajax Posted: Oct 24, 2008 9:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Amos King.
Original Post: Ajax And Non-Ajax
Feed Title: DirtyInformation
Feed URL: http://feeds.feedburner.com/Dirtyinformation
Feed Description: Information about Ruby/Rails/JRuby/WebDevelpoment/whatever.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Amos King
Latest Posts From DirtyInformation

Advertisement

It took me a while to find out how to have a link work if a person has ajax enabled or not. So I thought I would share the solution.

#controller action
def new
  @partial = params[:partial] || 'about'
  respond_to do |want|
    want.html {}
    want.js { render :partial => @partial }
  end
end

#link in view
<%= link_to_remote 'link', :url => formatted_new_session_url(:partial => 'partial_name', :format => 'js'), :update => div, :method => :get, :html => { :href => new_session_url(:partial => 'partial_name') } %>

#loading partial in view

<%= render :partial => @partial %>

This will allow you to reload the page_contents partial through ajax, but will reload the whole page with the correct partial if the browser doesn't support JavaScript.

Read: Ajax And Non-Ajax

Topic: Product Owner as Lifeguard Previous Topic   Next Topic Topic: United Prosperity and Rails to Help Billions of Small Entrepreneurs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use