Jquery Shopify liquid template:单击会在不同的地址图标上显示相同的地址';s
我的最终目标是,当我单击第一个地址图标时,它必须显示绑定到它的地址映射,如Jquery Shopify liquid template:单击会在不同的地址图标上显示相同的地址';s,jquery,loops,conditional-statements,shopify,liquid,Jquery,Loops,Conditional Statements,Shopify,Liquid,我的最终目标是,当我单击第一个地址图标时,它必须显示绑定到它的地址映射,如Iframe,与第二个地址图标相同。我已经成功地将动态类添加到地址图标中,如Address,然后我也成功地使用地址图标单击Google map正在加载。主要问题是我在两个时间点都得到了地图位置,即Wink&Nod,或者Abhiruchi Mall。我通过将I的值更改为0或1并更改小于条件来检查I的值,同时我还将开关盒0或1洗牌。我99%的成功,但点击两个图标加载相同的地图。当我点击第一个地址图标Wink&Nod时,地图必须
Iframe
,与第二个地址图标相同。我已经成功地将动态类添加到地址图标中,如Address
,然后我也成功地使用地址图标单击Google map正在加载。主要问题是我在两个时间点都得到了地图位置,即Wink&Nod
,或者Abhiruchi Mall
。我通过将I
的值更改为0
或1
并更改小于条件来检查I
的值,同时我还将开关盒0
或1
洗牌。我99%的成功,但点击两个图标加载相同的地图。当我点击第一个地址图标Wink&Nod
时,地图必须显示,当我点击第二个地址图标Abhiruchi Mall
时,必须加载。目前,他们在点击两个图标时加载相同的地址。谢谢
Shopify液体模板
<div class="container main content main-wrapper">
{% if section.settings.image == nil %}
<h1 class="center">{{ page.title }}</h1>
<div class="feature_divider"></div>
{% endif %}
<div class="sixteen columns featured_links">
<div class="section clearfix feature">
{% for block in section.blocks %}
<div class="{% if section.settings.featured_promos_per_row == 2 %}eight columns {% cycle 'alpha', 'omega' %}{% elsif section.settings.featured_promos_per_row == 3 %}one-third column {% cycle 'alpha', '', 'omega' %}{% else %}four columns {% cycle 'alpha', '', '', 'omega' %}{% endif %} {% if section.settings.featured_links_style != blank %}{{ section.settings.featured_links_style }} {% cycle 'delay-025s', 'delay-05s', 'delay-075s', 'delay-1s' %}{% endif %} center">
{% if block.settings.link != blank %}
<a href="{{ block.settings.link }}">
{% endif %}
<div class="{% if section.settings.rounded_image != blank %}rounded{% endif %}">
{% if block.settings.image != nil %}
<img src="{{ block.settings.image | img_url: '300x' }}"
alt="{{ block.settings.image.alt }}"
data-src="{{ block.settings.image | img_url: '2048x' }}"
class="lazyload"
{% comment %} data-sizes="auto" {% endcomment %}
data-srcset=" {{ block.settings.image | img_url: '2048x' }} 2048w,
{{ block.settings.image | img_url: '1600x' }} 1600w,
{{ block.settings.image | img_url: '1200x' }} 1200w,
{{ block.settings.image | img_url: '1000x' }} 1000w,
{{ block.settings.image | img_url: '800x' }} 800w,
{{ block.settings.image | img_url: '600x' }} 600w,
{{ block.settings.image | img_url: '400x' }} 400w"
/>
{% else %}
{% capture i %}{% cycle "1", "2", "3", "4", "5", "6" %}{% endcapture %}
{{ 'collection-' | append: i | placeholder_svg_tag: 'placeholder-svg placeholder-svg--promotions' }}
{% endif %}
</div>
{% if block.settings.title != blank %}
<h3>{{ block.settings.title | escape }}</h3>
{% if section.settings.show_divider %}
<div class="feature_divider"></div>
{% endif %}
{% endif %}
{% if block.settings.link != blank %}
</a>
{% endif %}
{% if forloop.index <= 2 %}
<div class="address"></div>
{% endif %}
{% if block.settings.text != blank %}
{{ block.settings.text }}
{% endif %}
</div>
{% if section.settings.featured_promos_per_row == 2 %}
{% cycle '', '<br class="clear " />' %}
{% elsif section.settings.featured_promos_per_row == 3 %}
{% cycle '', '', '<br class="clear" />' %}
{% else %}
{% cycle '', '', '', '<br class="clear" />' %}
{% endif %}
{% endfor %}
</div>
{% if section.settings.contact_address != blank %}
<br class="clear" />
<div class="embed-container maps">
<iframe width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q={{ section.settings.contact_address | replace: ' ', '+' }}&z={{ section.settings.zoom_level }}&output=embed"></iframe>
</div>
{% endif %}
</div>
</div>
{%if section.settings.image==nil%}
{{page.title}}
{%endif%}
{section.blocks%中的块的%s}
{%if block.settings.link!=空白%}
{%endif%}
{%if-forloop.index我已经将我的脚本重构成这个,它工作得很好
$('.address').click(function(){
var j=$('.address').index(this);
switch (j) {
case 0 :
$('.embed-container, .maps').html('<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d945.7084267048235!2d73.8854388291583!3d18.536415399212462!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xdda3387f821de029!2sWink+%26+Nod!5e0!3m2!1sen!2sin!4v1525613363322" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>');
break;
case 1 :
$('.embed-container, .maps').html('<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3784.450403270009!2d73.81459871445705!3d18.463246687442403!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3bc2956a20fbac17%3A0x91987f7033fd2e3c!2sAbhiruchi+Mall+and+Multiplex!5e0!3m2!1sen!2sin!4v1525612885113" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>');
break;
default:
$('.embed-container, .maps').html(' <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d945.7084267048235!2d73.8854388291583!3d18.536415399212462!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xdda3387f821de029!2sWink+%26+Nod!5e0!3m2!1sen!2sin!4v1525613363322" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>');
break;
}
});
</script>
$('.address')。单击(函数(){
var j=$('.address').index(this);
开关(j){
案例0:
$('.embed container、.maps').html('');
打破
案例1:
$('.embed container、.maps').html('');
打破
违约:
$('.embed container、.maps').html('');
打破
}
});
$('.address').click(function(){
var j=$('.address').index(this);
switch (j) {
case 0 :
$('.embed-container, .maps').html('<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d945.7084267048235!2d73.8854388291583!3d18.536415399212462!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xdda3387f821de029!2sWink+%26+Nod!5e0!3m2!1sen!2sin!4v1525613363322" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>');
break;
case 1 :
$('.embed-container, .maps').html('<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3784.450403270009!2d73.81459871445705!3d18.463246687442403!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3bc2956a20fbac17%3A0x91987f7033fd2e3c!2sAbhiruchi+Mall+and+Multiplex!5e0!3m2!1sen!2sin!4v1525612885113" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>');
break;
default:
$('.embed-container, .maps').html(' <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d945.7084267048235!2d73.8854388291583!3d18.536415399212462!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xdda3387f821de029!2sWink+%26+Nod!5e0!3m2!1sen!2sin!4v1525613363322" width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>');
break;
}
});
</script>