Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery在自定义主题shopify中不起作用_Javascript_Jquery_Shopify_Liquid - Fatal编程技术网

Javascript JQuery在自定义主题shopify中不起作用

Javascript JQuery在自定义主题shopify中不起作用,javascript,jquery,shopify,liquid,Javascript,Jquery,Shopify,Liquid,我正在尝试在注册期间根据客户的电子邮件标记他们。在此之前,jQuery在添加到customers/register.liquid中时运行良好,即使我将theme.liquid添加到“首次亮相”主题中。这是代码 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <input type="hidden" id="customer_tags"

我正在尝试在注册期间根据客户的电子邮件标记他们。在此之前,jQuery在添加到customers/register.liquid中时运行良好,即使我将theme.liquid添加到“首次亮相”主题中。这是代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<input type="hidden" id="customer_tags" name="customer[tags]"/>
        <script>
            jQuery('#{{ formId }}-email').on('input', function() {
         val = jQuery(this).val()
  if (val.indexOf('mycompany.com') !== -1) {
jQuery('#customer_tags').val('employee')
  } else {
  jQuery('#customer_tags').val('')
  }
          });</script>
在注册表中,我添加了jquery,并与主题电子邮件id匹配:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
{% form 'create_customer' %}
            {{ form.errors | default_errors }}

            <div id="first_name" class="clearfix large_form">
                <label for="first_name" class="login">{{ 'customer.register.first_name' | t }}</label>
                <input type="text" value="" name="customer[first_name]" id="first_name" class="large" size="30" />
            </div>

            <div id="last_name" class="clearfix large_form">
                <label for="last_name" class="login">{{ 'customer.register.last_name' | t }}</label>
                <input type="text" value="" name="customer[last_name]" id="last_name" class="large" size="30" />
            </div>

            <div id="email" class="clearfix large_form">
                <label for="email" class="login">{{ 'customer.register.email' | t }}</label>
                <input type="email" value="" name="customer[email]" id="email" class="large" size="30" />
                <input type="hidden" id="customer_tags" name="customer[tags]"/>
                <script>
                    jQuery( document ).ready(function() {
                    jQuery('#email').on('input', function() {
                    val = jQuery(this).val()
                        if (val.indexOf('yspsah.com') !== -1) {

                          jQuery('#customer_tags').val('employee')
                    } else {

                        jQuery('#customer_tags').val('')
                     }
                })});</script>
            </div>

{%form'创建客户'%}
{{form.errors | default_errors}}
{{'customer.register.first{u name}
{{'customer.register.last_name'|t}
{{'customer.register.email'|t}
jQuery(文档).ready(函数(){
jQuery('#email')。on('input',function(){
val=jQuery(this).val()
如果(val.indexOf('yspsah.com')!=-1){
jQuery(“#客户标签”).val('employee')
}否则{
jQuery(“#客户标签”).val(“”)
}
})});
然而,这一次,自动标签似乎不起作用。即使我把jquery放在theme.liquid上,仍然不能解决这个问题。
有人认为我应该设法解决这个问题吗?谢谢大家!

根据我的建议,您必须阅读customers/createwebhook,它返回注册客户的JSON数据,在这里,您可以根据您的需求将标签设置为customer。请参阅此无需在任何主题文件中更新。您在控制台中遇到了什么错误?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
{% form 'create_customer' %}
            {{ form.errors | default_errors }}

            <div id="first_name" class="clearfix large_form">
                <label for="first_name" class="login">{{ 'customer.register.first_name' | t }}</label>
                <input type="text" value="" name="customer[first_name]" id="first_name" class="large" size="30" />
            </div>

            <div id="last_name" class="clearfix large_form">
                <label for="last_name" class="login">{{ 'customer.register.last_name' | t }}</label>
                <input type="text" value="" name="customer[last_name]" id="last_name" class="large" size="30" />
            </div>

            <div id="email" class="clearfix large_form">
                <label for="email" class="login">{{ 'customer.register.email' | t }}</label>
                <input type="email" value="" name="customer[email]" id="email" class="large" size="30" />
                <input type="hidden" id="customer_tags" name="customer[tags]"/>
                <script>
                    jQuery( document ).ready(function() {
                    jQuery('#email').on('input', function() {
                    val = jQuery(this).val()
                        if (val.indexOf('yspsah.com') !== -1) {

                          jQuery('#customer_tags').val('employee')
                    } else {

                        jQuery('#customer_tags').val('')
                     }
                })});</script>
            </div>