rails render view onclick with javascript

前端 未结 3 1520
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 20:25

I\'m trying to create a view, where users can click on different buttons and render different content based on the buttons they click. I\'ve tried getting this done with JS but

3条回答
  •  孤城傲影
    2021-01-26 20:51

    It sounds like you need jQuery for this.

    You can wrap the rendered partial in a parent div with a hide class. When the button is clicked toggle displaying the content.

    http://api.jquery.com/show/

    $('#your-button').click(function(e){
        $('.hidden-div').toggleClass('hide');
    });
    

提交回复
热议问题