[英]Gon watch not working Rails 4
你試過了嗎:
<%= Gon::Base.render_data %>
代替:
<%= include_gon(:init => true) %>
?
在rails文件中,它應格式化為gon.watch.variable_name,但不能格式化為.js文件。
在.js文件中,它的格式應如下:
gon.watch('variable_name', function() {});
例如,如果您從TasksController獲取任務列表,則應該:
gon.watch.tasks = Task.all
在你的.js文件中:
gon.watch('tasks', function(tasks) {
//do something with tasks
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.