nobosh wrote:
> On Sep 23, 8:37�am, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
>> > Any pointers, tips, tutorials? thanks!
>>
>> This is fairly simple Ajax. �What part do you need help with?
> 
> Thanks Marnen. Right now I need helping understanding the end to end
> flow in Rails. I could use help with the following example.. Lets take
> Facebook.
> When you're on Facebook.com, and click MESSAGES, the URL changes to
> (facebook.com/?sk=messages) and then AJAX is used to download the HTML/
> JS content which is injected with JavaScript into the content
> pannel... No browser refresh which is what I'm after.

Apparently you need to understand how Ajax works.  This has nothing to 
do with Rails specifically.  I'd advise finding a good Ajax tutorial 
(don't know of one to recommend off the top of my head).

Basically, the major concept behind Ajax is that JavaScript can tell 
your browser make asynchronous HTTP requests.  Your Web server will 
process those requests just like any other HTTP request, but then the 
JavaScript takes back over and processes whatever got returned from the 
server.


> 
> My specific questions are:
> 1. For the content that is download via AJAX, is that content coming
> from a rails partial?... like
> (app>views>messages>_messagestable.html.erb

That's usually what you'd want to do.  You could also return JSON and 
process it on the client side, if you're more interested in data 
manipulation than display.

> 2. Where should the JavaScript reside that knows to fetch the messages
> content and then inject the content into the content panel? (is that
> the application.js?

Probably not.  It depends on the structure of your application, but 
you'll normally want a page-specific JS file to do this.

> 3. Once the messages content (_messagestable.html.erb) is injected
> into the content panel, it will require new JavaScript functions
> specific to that content... Where should that live?

Probably in the same page-specific JS file.  Again, there's no one 
answer; put it wherever your logic flow and refactoring dictate.

And for the love of God, provide a graceful degradation path so that 
people without JS can use as much of your app as possible.  (Yes, in 
2010, there are still a surprising number of users who cannot support 
JavaScript.)

> 
> Thanks

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to