你如何在algolia wordpress插件中实现no-autocomplete类?

时间:2017-08-10 10:58:05

标签: php wordpress autocomplete algolia

我不能在algolia的wordpress插件中使用no-autocomplete类,

我做错了什么?

<script type="text/html" id="tmpl-autocomplete-post-suggestion">
  <a class="suggestion-link" href="{{ data.permalink }}" title="{{ data.post_title }}">
    <# if ( data.images.thumbnail ) { #>
      <img class="suggestion-post-thumbnail" src="{{ data.images.thumbnail.url }}" alt="{{ data.post_title }}">
      <# } #>
      <div class="suggestion-post-attributes">
        <span class="suggestion-post-title" >{{{ data._highlightResult.post_title.value }}}</span>
        <!-- <# if ( data._snippetResult['content'] ) { #>
        <span class="suggestion-post-content">{{{ data._snippetResult['content'].value }}}</span>
        <# } #> -->
      </div>
      <div class="suggestion-taxonimies-attributes">
        <# if ( data.taxonomies.product_visibility == "outofstock") { #>
          <span class="suggestion-taxonomies-product-visibility ">Out of Stock</span>
          <div class="suggestion-taxonimies-attributes">
            <# if ( data.taxonomies.product_visibility == "exclude-from-search") { #>
              <span class="no-autocomplete"></span>
              <# } #>


            </a>
          </script>

以下是我要实施的具体代码。

<div class="suggestion-taxonimies-attributes">
            <# if ( data.taxonomies.product_visibility == "exclude-from-search") { #>
              <span class="no-autocomplete"></span>
              <# } #>

1 个答案:

答案 0 :(得分:0)

如果您使用的是jQuery,请尝试以下代码:

$('#tmpl-autocomplete-post-suggestion').append('<div class="suggestion-taxonimies-attributes"><# if ( data.taxonomies.product_visibility == "exclude-from-search") { #><span class="no-autocomplete"></span><# } #>');