Thanks Marnen but it sounds like I could use some help from a Rails
3 / AJAX guru on this one. Anyone?

On Sep 23, 4:51 pm, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> nobosh wrote:
> > Thanks Marnen. I feel ok about how AJAX works perhaps I wasn't asking
> > the question well enough. I did a little more digging and can show an
> > example that might help clear out what I'm working to understand in
> > Rails 3....
>
> I've never used Rails 3, and I do little enough Ajax development that I
> have to check references every time.  But with that in mind...
>
>
>
> > The goal, is to be able to inject html content into a contentPanel on
> > a page w/o page refresh (like Facebook, clicking messages)
>
> > In my case I want to inject the Books view into the contentPanel w/o
> > the layout, so in the Books controller I added:
>
> > def index
> >  respond_to do |format|
> >   format.html
> >   format.js  { render :layout => false }
> >  end
> > end
>
> This is almost certainly not what you want.  Even on Ajax requests,
> you're requesting HTML, not JavaScript, so you're still dealing with the
> format.html case. Just test request.xhr? to figure out if it was
> responding to an Ajax call.
>
>
>
>
>
>
>
> > Then in my application.js file, I have the following function being
> > triggered:
>
> >  jQuery.ajaxSetup({ 'beforeSend': function(xhr)
> > {xhr.setRequestHeader("Accept", "text/javascript")} })
>
> >  $.ajax({
> >   url: '/notes',
> >   success: function(data) {
> >     $('.contentCol').html(data);
> >     //alert('Load was performed.');
> >    }
> >  });
>
> > I also added a index.js.erb file, right now it just says:
> > You found me!
>
> The .js says it's JavaScript.  That's your cue to realize that you
> shouldn't be doing it that way if you're wanting HTML.  (Actually, I
> believe js.erb is usually a sign of a design problem.)
>
>
>
> > What's strange is I want to inject the books view without the layout
> > in the contentPanel div, so it doesn't seem right to be having that in
> > a index.js.erb file.....
>
> Exactly.  See above.
>
>
>
> > Does this help? Can't wait to hear your feedback, I've been trying to
> > tackle this one all morning.
>
> > Thanks!
>
> Best,
> -- 
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> Posted viahttp://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