Rails 3:原型到jQuery问题 [英] Rails 3 : prototype to jquery question

查看:72
本文介绍了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" %>')

  1. 将选择器更改为ID前面有#
  2. 使用 jquery .html()函数代替update
  1. Change the selector to have a # in front of the id
  2. use the jquery .html() function instead of update

这篇关于Rails 3:原型到jQuery问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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