Rails update.js.erb not executing javascript

后端 未结 7 1893
[愿得一人]
[愿得一人] 2020-12-13 18:35

I am building a form in rails that will edit an existing question via ajax.

After the form is submitted and the question has been updated, the update method in the c

7条回答
  •  一向
    一向 (楼主)
    2020-12-13 19:24

    In your update.js.erb file you need to escape javascript wherever you execute ruby code.

    $('.container').empty().append('<%=
      escape_javascript(
        render 'update'
      )
    %>')
    

    This is what solved it for me ...

提交回复
热议问题