Created
November 21, 2024 21:48
-
-
Save andreibabor/8019f82d437ace0c7c8d6a76b2cc4337 to your computer and use it in GitHub Desktop.
Pass schema variables to JavaScript - Shopfiy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It seems that the liquify variables must applied outside the {{ javascript }} section. Setting the following after the section html did the trick: | |
{%- assign row_height = section.settings.row_height -%} | |
{%- assign spacing = section.settings.spacing -%} | |
<script> | |
var rwhgt = {{ row_height | json }}; | |
var spcng = {{ spacing | json }}; | |
</script> | |
Then I was able to use rwhgt and spcng in the {{ javascript }} section like this: | |
{% javascript %} | |
$('.gallery-container').justifiedGallery({ | |
lastRow : 'center', | |
rowHeight : rwhgt, | |
margins : spcng | |
}).on('jg.complete', function () { | |
$('.image-popup').magnificPopup({ | |
type:'image', | |
gallery:{enabled: true} | |
}); | |
}); | |
{% endjavascript %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment