我想在 simple_captcha 图像下有一个链接。单击链接应重新加载 simple_captcha 图像。我在 gem 中找不到有关它的任何信息。我怎样才能更新它?感谢您的提前。
最佳答案
在找到下面提到的解决方案后,我也遇到了同样的问题。 因为我已经使用 jquery 刷新验证码 div 这是我用来刷新验证码的 javascript 代码。
$(document).ready(function() {
$(".refresh_image").click(function() {
$('#captcha').load("/users/dashboard/refresh_captcha_div");
});
});
此后,将验证码的 View 页面代码放入部分文件中,并在每次通过粘贴上述代码单击刷新 div(任何链接或按钮)时渲染该部分。它将调用您需要仅渲染部分的操作。 (这里是用户/仪表板 Controller 中的refresh_captcha_div)。下面是我的查看文件代码,供引用。
<div id ="captcha">
<%= render "simple_captcha_institute"%>
</div>
<%=link_to (image_tag "/assets/refresh_image.png"),"#", :class => "refresh_image"%>
这是我渲染部分的 View 页面代码,然后部分中的代码是
<div id="refresh_captcha">
<%= show_simple_captcha(:object=>"institute", :label => "Type The Above Characters..") %>
</div>
关于ruby-on-rails - 如何重新加载 simple_captcha 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9820489/