[英]How to render ruby code inside Coffescript .js.coffee
我點擊選擇列表時嘗試渲染部分。
為什么這會渲染部分文件而沒有問題:
users / index.html:
<%= select_tag :priority, options_for_select([['low'],
['normal'],
['high'],
['critical']]),
data: {form: escape_javascript(render(:partial => "my_partial_file"))}
%>
<div id="div_teste">
CHANGE IT!
</div>
assets / javascript / user.js:
$ ->
$('#priority').change ->
$('#div_test').html($('#priority').data('form'))
但是,如果我嘗試這個代碼:
$ ->
$('#priority').change ->
my_data = "<%= j render my_partial_file %>"
$('#div_test').html(my_data)
它只是渲染純文本而不是部分文件:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.