rails如何做调查弹出窗口

如何做调查弹出窗口?,我有两个按钮“投票”、“查看”,查看可以用java script做,但是submit后就必须redirect_to(),我希望主页不做任何刷新之类的操作(比如,:action=>"index"),提交后在弹出窗口中查看投票情况,求高手帮忙,

用延时的办法了,submit时用Ajax发送更新数据库,无须返回HTML片断,延时弹出窗口,这样提交的数据就能反映在弹出窗口中了,不过我始终觉得这不是最好的办法!

main_controller.rb
class MainController < ApplicationController
              def index
              end
              def indagate
                @info=InfoCount.find(:first)
                if params[:sub]=="提交"
                        case params[:item]
                                when "0"
                                @info.votes_best_add
                                when "1"
                                @info.votes_better_add
                                when "2"
                                @info.votes_good_add
                        end
                end
        end        
        def vote
                @info=InfoCount.find(:first)
        end
----------------------
info_count.rb
class InfoCount < ActiveRecord::Base
        def votes_good_add#自加
                self.class.increment_counter :votes_good, id
        end
        def votes_better_add#自加
                self.class.increment_counter :votes_better, id
        end
        def votes_best_add#自加
                self.class.increment_counter :votes_best, id
        end
end
------------------
index.rhtml
<script language="javascript">
<!--
function popup() {
    window.open('/main/vote','window','width=550,height=388,toolbar=no,   status=no,   menubar=no,   resizable=no,   scrollbars=yes');
}
function vote() {
    setTimeout("popup()",1000);
}
-->
</script>
<%=javascript_include_tag "prototype"%>
<%=form_remote_tag(:url=>{:action=>:indagate})%>
<br>
<INPUT type=hidden value=1 name=id>
<INPUT type=radio value=0 name=item>好。<BR>
<INPUT type=radio value=1 name=item>一般。<BR>
<INPUT type=radio value=2 name=item>差。<BR><BR>                                       
<input type="button" name="display" value="查看" onClick=popup()>                                       
<input type="submit" name="sub" value="提交" onClick=vote()>       
  <%= end_form_tag %>

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值