在加载时显示可用性而不是单击

时间:2017-01-26 11:32:33

标签: jquery

我在网上商店工作,这对我来说很新。 我们在产品详细信息页面上有一个链接,显示产品店的可用性。问题是此信息仅在客户点击链接时显示。我想要的是在页面加载时显示信息。

以下是产品链接:

https://www.bikemore.at/FAHRRAD/STEVENS-Fully-SLedge-27-5-18-anodized-black.htm?SessionId=&a=article&ProdNr=516041167&p=3&rdeocl=1&rdetpl=productpage&rdebox=box1

您会看到信息“VorOrtverfügbar?Jetztprüfen”,它显示了客户点击它时的可用性。

然后发生以下事件:

    <div id="availability_branches{availability_variantennr}" class="availability_branches mt-s">
  <script type="text/javascript"><!--
    jQuery(document).ready(function($) {
      $(".varop .var-ebene select").change(function() {
        $("#availability_branches{availability_variantennr} .availability_branches_content").hide();
        $("#availability_branches{availability_variantennr} .link_open").show();
      });
      $("#availability_branches{availability_variantennr} .link_open a").click(function() {
        var data, bError;
        bError = false;
        data = { };
        if (VariantenSeite) {
          if (IsGewaehlt()) {
            if ($("#availability_branches{availability_variantennr} .varnr").text() != document.eingabe.Var.value) {
              data.VariantenNr = document.eingabe.Var.value;
              if ($("#availability_branches{availability_variantennr} .availability_branches_content").text() != "")
                $("#availability_branches{availability_variantennr} .availability_branches_content").text("");
            }
          } else {
            bError = true;
            alert('{s}Bitte wählen Sie zunächst die von Ihnen gewünschte Variante aus!{e}');
          }
        }
        if (!bError) {
          if ($("#availability_branches{availability_variantennr} .availability_branches_content").text() == "") {
            $.ajax({
              url: "{URL_AVAILABILITY_BRANCHES}",
              type: "GET",
              data: data,
              cache: false
            })
            .done(function(msg) {
              $("#availability_branches{availability_variantennr} .availability_branches_content").html(msg);
              if (VariantenSeite)
                $("#availability_branches{availability_variantennr} .varnr").text(data.VariantenNr);
              $("#availability_branches{availability_variantennr} .availability_branches_content").show();
              $("#availability_branches{availability_variantennr} .link_open").hide();
              $("#availability_branches{availability_variantennr} .link_close a").click(function() {
                $("#availability_branches{availability_variantennr} .availability_branches_content").hide();
                $("#availability_branches{availability_variantennr} .link_open").show();
              });
            })
          } else {
            $("#availability_branches{availability_variantennr} .availability_branches_content").show();
            $("#availability_branches{availability_variantennr} .link_open").hide();
            $("#availability_branches{availability_variantennr} .link_close a").click(function() {
              $("#availability_branches{availability_variantennr} .availability_branches_content").hide();
              $("#availability_branches{availability_variantennr} .link_open").show();
            });
          }
        }
      });
    });
  //--></script>
  <div class="link_open"><a href="javascript:void(0)" title="{availability_linktext}" rel="nofollow" class="highlink magenta fontsize12 hover"><strong><i class="fa fa-map-marker" aria-hidden="true"></i> {availability_linktext}</strong></a></div>
  <div class="hide varnr"></div>
  <div class="availability_branches_content"></div>
</div>

1 个答案:

答案 0 :(得分:0)

只需将点击处理程序中的匿名函数移动到$('document')。ready method body。

通过删除以下行很容易实现:

});
      $("#availability_branches{availability_variantennr} .link_open a").click(function() {