Closed jpmckearin closed 9 years ago
UPDATE
I was having trouble figuring out what needed to be done to handle the expire event.
Reading through the source of angular-recaptcha.js, I found the "reload" function
vcRecaptchaService.reload()
this was very helpful to me when I was setting up recaptcha, just thought I'd post it here since it's not in the docs
Do you guys have any tips on how you handle the "expire" event?
@jpmckearin @iambrosi
@trickpattyFH20 There is no need to vcRecaptchaService.reload()
when the timeout callback is called, it is just to notify the developer of the timeout so they can display messages or do whatever. Internally, the now invalid captcha response is cleared out of model and if the captcha is within a form control it will mark the form as invalid. Google internally resets the captcha.
@TheSharpieOne the functionality I was looking to achieve was the have a new empty re-captcha shown after a timeout on the re-captcha key on google's end. no sense in making a user refresh the page to get a new re-captcha when I can do it asynchronously in the timeout callback
@trickpattyFH20 I see, you wanted a brand-new recaptcha instance rather than reusing the old one (by reuse, I mean "unchecking" the checkbox and allowing the user to "check" the same checkbox again). But really, vcRecaptchaService.reload()
is not a "reload", it just calls recaptcha's reset()
, which resets the same checkbox rather than creating a new instance.
Also, just fyi, without this module, or any additional code, the functionality you want happens automatically in recaptcha's code... give it a try.
Just don't want to make people think they have to use the callback to reset recaptcha, because they don't. Resetting the captcha happens automatically, asynchronously, and without the need to reload/refresh the page. The callback is just a convenience to let the developer be notified that the valid recaptcha has timed out.
ah ok, I didn't know the vanilla recaptcha code included that functionality, I just used this module for the convenience of it, thank you! @TheSharpieOne
Thanks @jpmckearin !