I have an Ajax form in my Rails app that contains the Recaptcha markup as provided by the helper in the Ambethia Recaptcha gem:
recaptcha_tags :ajax => true
On submit, the form hits a create action, which responds with the create.js.erb that contains the following:
$('#message-form').replaceWith("<%= escape_javascript(render('message')) %>");
The 'message' partial contains the same form markup that was originally rendered, including recaptcha_tags, but may also display if there were errors in the validation at this point.
In Firefox, the form gets re-rendered and displays a refreshed Captcha. But for some reason, in Webkit browsers (Safari and Chrome), the 'dynamic_recaptcha' Recaptcha element gets emptied, as if Recaptcha.create(public_key, element_id) never gets called.
In the Safari Developer console, I am able to call Recaptcha.create(public_key, element_id) and regenerate a Captcha.
Can anyone tell me what's going on here? Thanks.