Rails 3.1与3.0 AJAX语法差异. jQuery中的等效语句? [英] Rails 3.1 vs 3.0 AJAX syntax difference. Equivalent statement in jQuery?

查看:90
本文介绍了Rails 3.1与3.0 AJAX语法差异. jQuery中的等效语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

研究使用Rails进行敏捷Web开发"第4版,并阅读有关开始AJAX的部分. (第11章迭代F2).在示例代码中,使用Rails 3.0的书建议创建:

Working through "Agile Web Development with Rails" edition 4 and hit the section on beginning AJAX. (Chapter 11 iteration F2). In the example code, the book using Rails 3.0 recommends creating:

app/views/line_items/create.js.rjs,其中文件仅包含:

app/views/line_items/create.js.rjs with the file only containing:

page.replace_html('cart', render(@cart))

使用jQuery的Rails 3.1的等效实现是什么?

What would an equivalent implementation for rails 3.1 using jQuery be?

app/views/line_items/create.js.erb?

app/views/line_items/create.js.erb?

$('#cart').html(?something magical here?)

推荐答案

您最好这样做:

$('#cart').html("<%= escape_javascript(render(@cart)) %>");

这篇关于Rails 3.1与3.0 AJAX语法差异. jQuery中的等效语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆