jquery - 如何在 jquery_ujs 响应中的 Javascript ERB 模板中调用 Coffeescript 模板?

标签 jquery ruby-on-rails coffeescript ujs

我正在使用Coffeescript template在我的 Rails 3.1 应用程序中,所以在我的 app/assets/javascripts/post.js.coffee 文件中,我有类似的内容:

$('#post').html JST['templates/posts/show'] post: post

其中 post 是一个 JSON 对象。模板位于 app/assets/javascripts/templates/posts/show

现在我也使用 jquery_ujs 来响应 PostsController#create 并希望使用 app/views/posts/show.js.erb 来呈现响应。在 show.js.erb 中,我想使用上面的模板。我该怎么做呢?谢谢。

最佳答案

看起来像https://github.com/markbates/coffeebeans可能就是您正在寻找的。

关于jquery - 如何在 jquery_ujs 响应中的 Javascript ERB 模板中调用 Coffeescript 模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7616414/

相关文章:

javascript - 链接 p :schedule prev next button to p:calendar like google calendar

ruby-on-rails - rails 服务器 bin/rails :6: warning: already initialized constant APP_PATH error

javascript - 在 View 的事件属性中使用 backbone.js 监听与 @el 相关的事件

mysql - 如何在文本框中限制 '♥♣'个字符

ruby-on-rails - 有没有办法在 Rails 3.1 中检测用户代理

javascript - 如何查看一个类是否已经被实例化

JavaScript 继承和 super 构造函数

javascript - 无需解析即可获取ajax输出

Jquery更改隐藏表单字段值

javascript - 我正在使用 camanJS 对照片应用滤镜。目前遇到应用滤镜裁剪照片的问题