Skip to content

Commit

Permalink
Fixed #25: Use DOM to load JS script
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael H. Arieli committed Nov 20, 2014
1 parent 7340009 commit 056bd28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions Resources/views/Form/ewz_recaptcha_widget.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
<?php else ?>
<div id="ewz_recaptcha_div"></div>

<script src="<?php echo $url_api ?>" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.onload = function() {
Recaptcha.create('<?php echo $public_key ?>', 'ewz_recaptcha_div', <?php echo json_encode($attr['options']) ?>);
});
}
script.src = '<?php echo $url_api ?>';
document.getElementsByTagName('head')[0].appendChild(script);
</script>
<?php endif ?>
<?php endif ?>
9 changes: 6 additions & 3 deletions Resources/views/Form/ewz_recaptcha_widget.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
{% else %}
<div id="ewz_recaptcha_div"></div>

<script src="{{ form.vars.url_api }}" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.onload = function() {
Recaptcha.create('{{ form.vars.public_key }}', 'ewz_recaptcha_div', {{ attr.options|default({})|json_encode|raw }});
});
}
script.src = '{{ form.vars.url_api }}';
document.getElementsByTagName('head')[0].appendChild(script);
</script>
{% endif %}
{% endif %}
Expand Down

0 comments on commit 056bd28

Please sign in to comment.