Rails 3:原型到jQuery问题 [英] Rails 3 : prototype to jquery question
本文介绍了Rails 3:原型到jQuery问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将这些create.js.erb和destroy.js.erb文件从原型切换到jquery?
How do I switch these create.js.erb and destroy.js.erb files from prototype to jquery?
$("follow_form").update("<%= escape_javascript(render('users/unfollow')) %>")
$("followers").update('<%= "#{@user.followers.count} followers" %>')
destroy.js.erb
$("follow_form").update("<%= escape_javascript(render('users/follow')) %>")
$("followers").update('<%= "#{@user.followers.count} followers" %>')
这是我的应用程序中仅有的原型产品,我想切换到jquery并开始从那里学习.感谢您的帮助!
This is the only prototype stuff I have in my app and I want to switch over to jquery and start to learn from there. Thanks for any help!
推荐答案
极为相似
$("#follow_form").html("<%= escape_javascript(render('users/unfollow')) %>")
$("#followers").html('<%= "#{@user.followers.count} followers" %>')
- 将选择器更改为ID前面有#
- 使用 jquery .html()函数代替
update
- Change the selector to have a # in front of the id
- use the jquery .html() function instead of
update
这篇关于Rails 3:原型到jQuery问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文