Thursday, July 28, 2011

[Rails] Re: Rails, jquery and Ajax

Railscasts has some examples:

http://railscasts.com/episodes/43-ajax-with-rjs
http://railscasts.com/episodes/136-jquery

On 27 jul, 08:45, Paul Bergstrom <li...@ruby-forum.com> wrote:
> How do I make an ajax call and then update a div with a partial? I've
> tried this but it's not working. Comment is created but the partial is
> not loaded.
>
> //view
>       <a href="#" id="testlink">Testlink</a>
>       <div id="commentlist">
>
>       </div>
>
> //controller
>   def new
>
>       @comment = Comment.new
>       @comment.save
>
>       respond_to do |format|
>         format.html { }
>         format.js { }
>       end
>
>   end
>
> //js
> $(function() {
>
>   $('#testlink').click(function() {
>     $.ajax({
>        type: "GET",
>        url: "/comments/new",
>        success: function(){
>         $('#commentlist').html('<%= render :partial => "comments" %>')
>
>        }
>     });
>   });
>
> });
>
> --
> 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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate