Tag: ruby on rails 3

Rails 3和jQuery网站的富文本格式(RTF)编辑器插件?

你使用哪种RTF编辑器? 我们使用的是Rails 3和jQuery,并希望实现一个低维护的RTF编辑器。 我们更喜欢使用第三方插件而不是从头开始构建。 你今天使用哪一个,有哪些优点/缺点?

在rails 3.1中每10秒重新加载一页

我有一个rails 3.1rc4应用程序,我想在每10秒后更新我的index.html.erb文件中的div。 如果可以通过jquery完成,我不会这样做吗? 有一个更新方法,但我不,如果它只是原型。 任何样本都会很棒

如何让Rquery动画在Rails 3.2.8中工作?

我在我的Rails应用程序中使用jQuery的animate()方法。 但是,我无法让它发挥作用。 这是我的application.js文件: //= require jquery //= require jquery_ujs //= require_tree . 我尝试在那里添加//= require jquery-ui ,但它导致我的应用程序崩溃: couldn’t find file ‘jquery-ui’ 谁能告诉我我失踪了什么? 谢谢你的帮助。

使用Rails通过Ajax添加Twitter Bootstrap Popover

我正在尝试通过带有rails的ajax调用添加一个popover。 我在firebug中看到内容加载正常,但弹出窗口没有加载。 所有其他弹出窗口都在页面上工作,如果我重新加载页面,弹出窗口也可以工作……但它只是在ajax调用上不起作用。 我错过了什么? update.js $(“#new-pins”).append(“<img src='https://stackoverflow.com/images/.png’ class=’pinimage’ data-content=’hello’ data-original-title=”>”) show.html popover javascript: $(function () { $(‘.pinimage’).popover({ html : true }); }); 这是在ajax调用之后加载的内容: 感谢您的任何帮助!

Rails 3 – 如何使用jQuery使整个表行可单击

我有一个私人消息系统,显示所有收到的消息的“收件箱”视图。 此视图只是通过在视图中使用块创建的多个表行生成的。 我想让每个表行“可点击”并传递一个参数(就像我使用标准的link_to一样)。 但是,正如您可能知道的那样,您不能像div那样制作可点击的tr。 因此,我相信解决方案需要一些简单的jQuery。 我找到了这个问题的部分答案,但不完整。 我知道下面的代码是不正确的(link_to部分),但有人可以告诉我如何使用jQuery单击function连接rails link_to链接? 谢谢! $(‘tr’).click(function() { “messages”, :action => “show”, :id => msg.convo_id %> });

如何将json响应传递回客户端

在我的ruby on rails代码中,我想将json响应发送回客户端。 由于我是新手上的ruby,我不知道我该怎么做。 我想发送error = 1 and success = 0作为json数据,如果数据没有保存到数据库,如果它成功保存它应该发送success = 1 and error = 0请参阅下面的代码 这是我的控制器 class ContactsController @result.to_json } end else render “new” end end end 这是我的javascript代码 $(‘.signupbutton’).click(function(e) { e.preventDefault(); var data = $(‘#updatesBig’).serialize(); var url = ‘contacts’; console.log(data); $.ajax({ type: ‘POST’, url: url, data: data, dataType: ‘json’, success: function(data) { console.log(data); […]

jQueryvalidation单独的年,月,日的日期字段

我分别有3个单独的字段和两个日期。 年,月,日期具有要选择的选项的drop down lists 。 我想validation表单以便To> From 。 我该如何实现? 从 Year: Month: Date: 至 Year: Month: Date:

如何在没有提交表单的情况下将值传递给rails模型方法?

我的模型中有一个类如下: class Project::Area < ActiveRecord::Base attr_accessor :cancel_id def save_loc_values update_record = Project::Loc.find_by_Project_Reference(project.Project_Reference) update_record.update_attributes({ Status: 'D', Cancellation_Date: DateTime.now().strftime("%Y-%m-%d %T.%L"), CancellationReason_id: self.cancel_id }) end end 在我的form ,我使用attr_accessor字段 我在我的controller创建了一个路由和我的自定义方法,如下所示, def save_loc_values @area = Project::Area.find(params[:area_id]) @return = @area.save_loc_values end 它中的问题工作正常,并将Status和Cancellation_Date的值保存到另一个数据库表中。 但是On change cancel_id值没有保存。 如何传递和保存onchange cancel_id ? 谢谢,我真的很感激你的帮助。

rails jquery ajax请求不执行

我正在我正在构建的应用程序上实现一个向上投票系统非常类似于stackoverflow上的应用程序。 当用户点击upvote或downvote时,会向我的一个控制器发送一个ajax请求,他们会更新几个表。 完成后,我使用respond_to路由到执行jquery的js.erb文件来更新用户显示。 但是,jquery没有被执行。 当我舔upvote / downvote时,控制器代码正确执行(我可以在rails控制台中看到它),但用户显示不会更新。 刷新后,用户显示更新,但不是异步。 我知道jquery没有在fire bug控制台中执行b / c我可以看到我的jquery代码 – 它只是没有被应用。 这是我的upvote控制器代码: def upvote @post = Post.find(params[:id]) @user_vote = current_user.votes.where(post_id: @post.id).first if @user_vote.blank? Vote.create(user_id: current_user.id, post_id: @post.id, vote: 1) @post.upvotes += 1 elsif @user_vote.vote.to_i == 0 @user_vote.vote = 1 @post.upvotes += 1 elsif @user_vote.vote.to_i == 1 return redirect_to :back, :alert => ‘You […]

javascript(jquery-rails)在rails 3.1.rc5中无法正常工作

每次我通过javascripts删除对象时使用remove方法都不起作用。 我的destroy.js代码如下。 $(“#”).remove(); $(‘#comment-count-‘).html(“”); 复数就可以了 我的_comment.html.erb如下 comment.user.name, :class => “avatar tip”, :title => comment.user.name %> comment.user.name, :class => “avatar tip”, :title => comment.user.name %> “profile-link-small” %> –– | “Are you sure you want to delete this comment?”, :method => :delete, :remote => true %> Delete 它用于工作之前,但在我更新到rails rc5之后它就会存在