update element in knockout template which was changed by 3td party library
- by yakov
I have 'div' element (recaptchaDiv) in knockout template which is not bound to any observable field: <div id="recaptchaDiv"></div>
On the other hand, I update this 'div' by 3rd party library. In particular, this is google recaptcha. This is my code:
Recaptcha.create("[my private key]", "recaptchaDiv", {
theme: "clean",
callback: Recaptcha.ToTest
});
And it doesn't work (I see nothing).
What I know:
trying on FF console: $("#recaptchaDiv").html() - it shows the expected html code, I just can't see it in the browser
What I tried:
to move recaptchaDiv outside of the template and it works: I can see the captcha in the browser
to bind recaptchaDiv on html property:
in the template:
<div id="recaptchaDiv" data-bind="html: recaptcha"></div>
in the model:
Recaptcha.create("[my private key]", "recaptchaDiv", {
theme: "clean",
callback: Recaptcha.ToTest
});
recaptcha($("#recaptchaDiv").html());
and it doesn't work
(replacing jquery on document.getElementById doesn't help)
Any help will be very much appreciated!!!
Thank you in advance.