简体   繁体   中英

How to update pagination by ajax after insert comment ajax in Ruby On Rails

I have a problem but i don't know how to solve it. Can anyone help me? I have Post table, Comment table. Now with a post i will have many comments with pagination on comments. I want to add a comment on that post by ajax, and then update pagination also by ajax. i'm newbie and don't know how to solve it. Help me and thank you very much !

Front site is perfectly explained here https://api.jquery.com/jQuery.post/ ex.

  function formSubmit(data){
  $.ajax({
         type: "GET",
         url: 'path-to-method-which-adds-comment',
         data: data,// must be in [something:somethin] form
         success: function(data)
         {

           $.get(url).done(function(data) {
            //if methods returns only this comment in correct form you can simply just paste it in
                $('#my_all_comments').append(data);
            });
         }

       });

return false;

}

And how do you want add this comment?

You can write method which would just save this comment and return this comment with all css properties and this jquery just paste it.

I don't know what you're thinking about but I that is nice concept

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM