如何重新加载简单的验证码图像

时间:2012-03-22 10:30:59

标签: ruby-on-rails

我想在simple_captcha图片下有一个链接。点击链接应该重新加载simple_captcha图像。我在gem中找不到任何有关它的信息。我该如何更新?谢谢你提前。

1 个答案:

答案 0 :(得分:2)

在找到下面提到的解决方案之后,我也遇到了同样的问题。 因为我使用jquery刷新验证码div这是我用来刷新验证码的javascript代码。

$(document).ready(function() {
  $(".refresh_image").click(function() {
    $('#captcha').load("/users/dashboard/refresh_captcha_div");
  });
});

此后将验证码的查看页面代码放入部分文件中,并在每次粘贴上述代码点击刷新div(任何链接或按钮)时呈现部分。它将调用您需要的动作,仅渲染部分动作。 (这里是用户/仪表板控制器中的refresh_captcha_div)。以下是我的查看文件代码供参考。

       <div id ="captcha">
         <%= render "simple_captcha_institute"%>
       </div>
         <%=link_to (image_tag "/assets/refresh_image.png"),"#", :class => "refresh_image"%>  

这是视图页面代码,其中我呈现部分,然后部分中的代码是

<div id="refresh_captcha">
  <%= show_simple_captcha(:object=>"institute", :label => "Type The Above Characters..") %>            
</div>
相关问题