update element in knockout template which was changed by 3td party library

Posted by yakov on Stack Overflow See other posts from Stack Overflow or by yakov
Published on 2012-10-11T15:33:43Z Indexed on 2012/10/11 15:36 UTC
Read the original article Hit count: 236

  1. I have 'div' element (recaptchaDiv) in knockout template which is not bound to any observable field: <div id="recaptchaDiv"></div>
  2. 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:

  1. trying on FF console: $("#recaptchaDiv").html() - it shows the expected html code, I just can't see it in the browser

What I tried:

  1. to move recaptchaDiv outside of the template and it works: I can see the captcha in the browser
  2. 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.

© Stack Overflow or respective owner

Related posts about templates

Related posts about knockout.js