Skip to content

Commit

Permalink
Merge pull request #118 from bencroker/patch-3
Browse files Browse the repository at this point in the history
Use `sprig.registerJs()` function
  • Loading branch information
lindseydiloreto authored Sep 6, 2024
2 parents 9c77b0d + 9b65944 commit b5aa61e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/guides/sprig.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ It is important that the map ID in the [`googleMaps.init` method](/javascript/go
{# When the map is reloaded by Sprig #}
{% if sprig.isRequest %}
<script>
{% set js %}
googleMaps.init('my-sprig-map');
</script>
{% endset %}
{% do sprig.registerJs(js) %}
{% endif %}
```

Expand All @@ -90,11 +91,12 @@ The `init` method also allows for an optional [callback method](/javascript/goog

```twig
{% if sprig.isRequest %}
<script>
{% set js %}
googleMaps.init('my-sprig-map', function () {
console.log("The map has finished loading!");
});
</script>
{% endset %}
{% do sprig.registerJs(js) %}
{% endif %}
```

Expand Down

0 comments on commit b5aa61e

Please sign in to comment.