genemu / GenemuFormBundle

Extra Form : Captcha GD, Tinymce, Recaptcha, JQueryDate, JQueryAutocomplete, JQuerySlider, JQueryFile, JQueryImage
587 stars 265 forks source link

ReCaptcha - Not showing when called with ajax #359

Open Molkobain opened 9 years ago

Molkobain commented 9 years ago

Hi,

I'm using recaptcha in a formtype with Symfony 2. It works fine when used in a "regular" way. But when I call a form with ajax, the recaptcha doesn't show.

My guess is that it's because the genemu initialization function is based on the document "onLoad" event. So when the ajax response comes it doesn't do anything.

In my case, I fixed it dirty by adding a setTimeout calling the genemu init function. But I thing it would better of if it was taking care of by the init function directly.

{{form_javascript(form)}}
<script type="text/javascript">
    $(document).ready(function(){
        window.setTimeout(function(){genemu_recaptcha_load();}, 2000);
    });
</script>
WedgeSama commented 9 years ago

Why do you exactly do with ajax? Maybe you can call genemu_recaptcha_load() if ajax succeed?

Molkobain commented 9 years ago

It's what I do as an alternative.

What I call with ajax is a controller that returns a form template in which the captcha is included. It works OK from a regular page display but not when call with ajax because the function's call is based on Dom loading state.

reypm commented 9 years ago

@WedgeSama this is exactly the same issue I have reported here days ago, any advice around this issue?

reypm commented 9 years ago

@Molkobain did I miss something? I tried exactly as you said in your first post and I can't get it to work see live example here pick Personal Natural, any help?

Molkobain commented 9 years ago

Hi,

the code from original post has to be in what you receive from ajax, not the landing page.

We can't check your link as you seem to have a right issue on the logs folder :

RuntimeException: Unable to create the logs directory (/var/www/html/sencamer/app/logs)
WedgeSama commented 9 years ago

Solution here #362

Molkobain commented 9 years ago

Coool :)