Rails - display results of index and show actions via ajax

前端 未结 2 565
日久生厌
日久生厌 2021-02-02 03:22

I have a very simple Post resource with two actions, index and show. My template contains a sidebar with links to each previous post. I want the sidebar links to displa

2条回答
  •  天涯浪人
    2021-02-02 04:01

    I don't have a full answer at hand, because I'm relatively new to this, too.

    But, I would start by taking a look at JQuery's get() method. You should be able to use that to call the index or show method. Those methods should return the html that you want to display in the non-sidebar section of the page. You can use get()'s callback handler to place that HTML into the appropriate div on the page.

    Sorry that this is a little vague, but if you play with this I bet you'll figure it out.

提交回复
热议问题