基于条件jQuery的液体脚本
我们假设我们有一个下拉切换:
<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>
而且我们也有一个liquid
代码:
{% include 'page' key: 'table' %}
对于key
,我提供了一些选项table> Table> Table
,table25
和table50
对于每个下拉选项值值。
我是liquid
的新手,但是我想创建一个jQuery
,该根据下拉列表选择key
值。
<script>
$(this).append("{% include 'page' key: 'table"+ $.("#num-of-records").val()+"' %}"
</script>
因此,假设我选择选项25
,因此(也许重新打开页面)附加liquid
of:
{% include 'page' key: 'table25' %}
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' %}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
液体是服务器端渲染语言。 jQuery是在液体之后渲染的,因此您无法以此方式进行。
一种可以起作用的方法(不是轻的方法)可能是渲染所有液体外壳,隐藏它们,然后通过使用jQuery显示您想要的一种。
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.