Announcement

Collapse
No announcement yet.

Add class if another IDis visibility: hidden

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Add class if another IDis visibility: hidden

    I am trying to make a 'notify me' link to fire a modal contact form if the product is out of stock. This is OK except that if the 'enable stock monitoring box' is unticked in Product Details the notify me text and icon appear regardless.

    I am trying to add a clas to #notifyme to hide it if 'EnableIfOutOfStock_<actinic:variable name="ProductReference" selectable="false" />' is 'visibility: hidden' but although the script should work it does not work in Sellerdeck!

    Please can anyone point me in the right direction?

    Thank you

    Code:
    <strong><span class="actrequired"><span id="EnableIfOutOfStock_<actinic:variable name="ProductReference" selectable="false" />" class="ActinicRTS" style="visibility: hidden; display: none;" data-message="<Actinic:Variable Name="OutOfStock"/>"></span></span></strong>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22StockLevel%22%20%2f%3e%20%3c%3d%20%3cactinic%3avariable%20name%3d%22StockSuspendLevel%22%20%2f%3e" >
    <script>
    $(document).ready(function(){
    if ($("#EnableIfOutOfStock_<actinic:variable name='ProductReference' selectable='false' />").attr("visibility") === "hidden") {
    $("#notify-icon").addClass("hideme");
    }
    else {}
    });
    </script>
    <div id="notify-icon" class="" data-toggle="modal" data-target="#notify-content"><i class="fa fa-bullhorn" aria-hidden="true"></i>&nbsp;Notify me!</div>
    </actinic:block>
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    You've invented .attr("visibility") so it will always return undefined.

    Try:
    Code:
    if ( $( "#EnableIfOutOfStock_<actinic:variable name='ProductReference' selectable='false' />" ).is( ":visible" ) )
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thank you Norman, that is one of the many variations I have tried. It is the Actinic Vaiable which is messing things up.

      https://www.graphiczdev.co.uk/Untitled-1.html

      Class not added (as in Sellerdeck)

      Code:
      <span id="EnableIfOutOfStock_<actinic:variable name='ProductReference' selectable='false' />" class="ActinicRTS" style="visibility: visible; display: inline;" data-message="">Hello mum</span>
      
      <script>
      $(document).ready(function(){
      if ( $( "#EnableIfOutOfStock_<actinic:variable name='ProductReference' selectable='false' />" ).is( ":visible" ) ) {
      $("#notify-icon").addClass("showeme");
      }
      else {}
      });
      </script>
      <div id="notify-icon" class="" data-toggle="modal" data-target="#notify-content"><i class="fa fa-bullhorn" aria-hidden="true"></i>&nbsp;Notify me!</div>
      https://www.graphiczdev.co.uk/Untitled-2.html

      Class added with no variable

      Code:
      <span id="EnableIfOutOfStock_51" class="ActinicRTS" style="visibility: visible; display: inline;" data-message="">Hello world</span>
      
      <script>
      $(document).ready(function(){
      if ( $( "#EnableIfOutOfStock_51" ).is( ":visible" ) ) {
      $("#notify-icon").addClass("showeme");
      }
      else {}
      });
      </script>
      <div id="notify-icon" class="" data-toggle="modal" data-target="#notify-content"><i class="fa fa-bullhorn" aria-hidden="true"></i>&nbsp;Notify me!</div>
      In Sellerdeck: https://www.graphiczdev.co.uk/swiftr...53.html#SID=13

      Code:
      <strong><span class="actrequired"><span id="EnableIfOutOfStock_<actinic:variable name="ProductReference" selectable="false" />" class="ActinicRTS" style="visibility: hidden; display: none;" data-message="<Actinic:Variable Name="OutOfStock"/>"></span></span></strong>
      
      <actinic:block if="%3cactinic%3avariable%20name%3d%22StockLevel%22%20%2f%3e%20%3c%3d%20%3cactinic%3avariable%20name%3d%22StockSuspendLevel%22%20%2f%3e" >
      
      <div id="notify-icon" class="" data-toggle="modal" data-target="#notify-content"><i class="fa fa-bullhorn" aria-hidden="true"></i>&nbsp;Notify me!</div>
      <script>
      $(document).ready(function(){
      if ( $("div[id^='EnableIfOutOfStock']").is( ":visible" ) ) {
      $("#notify-icon").addClass("showeme");
      }
      else {}
      });
      </script>
      </actinic:block>
      Click image for larger version

Name:	notaddingclass.jpg
Views:	65
Size:	135.0 KB
ID:	553042
      Attached Files
      Jonathan Chappell
      Website Designer
      SellerDeck Website Designer
      Actinic to SellerDeck upgrades
      Graphicz Limited - www.graphicz.co.uk

      Comment


        #4
        Of course it is not

        Code:
        if ( $("div[id^='EnableIfOutOfStock']").is( ":visible" ) ) {
        but
        Code:
        if ( $("span[id^='EnableIfOutOfStock']").is( ":visible" ) ) {
        Get there in the end - thank you again Norman
        Jonathan Chappell
        Website Designer
        SellerDeck Website Designer
        Actinic to SellerDeck upgrades
        Graphicz Limited - www.graphicz.co.uk

        Comment


          #5
          Spoke too soon...

          Works in offline preview but not on live site: https://www.graphiczdev.co.uk/swiftr...53.html#SID=13

          Click image for larger version

Name:	Untitled-2.jpg
Views:	88
Size:	290.2 KB
ID:	553045
          Jonathan Chappell
          Website Designer
          SellerDeck Website Designer
          Actinic to SellerDeck upgrades
          Graphicz Limited - www.graphicz.co.uk

          Comment


            #6
            Looks like those EnableIfOutOfStock fields are modified dynamically by stock control JavaScript. That JS probably runs long after document.ready so you'll need to locate that code and add yours to that. Look in actinicextras.js and dynamic.js.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment

            Working...
            X