You seem to be on the right track. Your opinion seems true with a quick look.
There are just a few final parts to this job, starting with the fact that your controller can accept js calls:
# Inside Controller action respond_to do |format| format.js end
Once you have configured this, you need to create javascript to return to the client for each call. Create files in the view folder
# app/views/controllerName/actionName.js.erb $('#ajax').html("<%= escape_javascript(render(:partial => 'content', :sortingType => 'type')) %>");
The above will allow you to display a partial that shows the messages (in this example I named this content), and pass partial to the sortingType local variable. This answer will be posted inside the html div id = "ajax" (from your example). The last step is to create a partial view that will make all your posts sorted the way you would like
# app/views/resourceName/_content.html.erb
I hope this brings you closer to your intentions.
Edit: implemented I had some problems with my quotes.
source share