Let's suppose we have a dropdown toggle:
<label for="num-of-records">Rows per Page: </label>
<select name="num-of-records" id="num-of-records">
<option value="" selected>default</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
And we also have a liquid
code:
{% include 'page' key: 'table' %}
For key
, I have provide some options table
,table25
, and table50
for each dropdown options value.
I am new to liquid
, but I want to create a jquery
which select the key
value based on the dropdown.
<script>
$(this).append("{% include 'page' key: 'table" $.("#num-of-records").val() "' %}"
</script>
So let's say I choose option 25
, so it will (maybe reopen the page) append liquid
script of:
{% include 'page' key: 'table25' %}
CodePudding user response:
Liquid is a server side rendered language. jQuery is rendered after Liquid so you cannot proceed this way.
An approach that could work (not a light one however) could be to render all your Liquid cases, hide them, then show the one you want by using jQuery.