skip to Main Content

I had implemented a range slider by referring this link:

How to create custom range sliders with min and max using CSS and JavaScript.

For its jquery-ui reference, I tried using below two versions

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>

Range slider is working fine with both the jQuery-ui versions. But below tab functionality does not work. It doesn’t hit on debugger inside its function after adding those jquery-ui versions. My jQuery version is jQuery v3.5.0.

$("#tabs").tabs({
    "onShow": function (el) {
        debugger;
    }
});

Can anyone suggest the reference of jquery-ui that support version v3.5.0.

2

Answers


  1. There is no onShow

    • "show" is not an event but used to set options

    • "load" event only triggers when loading the content from remote

    But you can use "create" plus activate and/or beforeActivate

    activate( event, ui )
    Type: tabsactivate
    Triggered after a tab has been activated (after animation completes). If the tabs were previously collapsed, ui.oldTab and ui.oldPanel will be empty jQuery objects. If the tabs are collapsing, ui.newTab and ui.newPanel will be empty jQuery objects.
    Note: Since the activate event is only fired on tab activation, it is not fired for the initial tab when the tabs widget is created. If you need a hook for widget creation use the create event.

    $("#tabs").tabs({
      "create": function(el,ui) { 
        console.log("running",ui.panel[0].id);
      },
      "beforeActivate": function(el,ui) { 
        console.log("clicked",ui.newPanel[0].id);
      },
      "activate": function(el,ui) { 
        console.log("activated",ui.newPanel[0].id);
      }
    });
    
    $("#tabs").tabs({
      "create": function(el,ui) { 
        console.log("running",ui.panel[0].id);
      },
      "beforeActivate": function(el,ui) { 
        console.log("clicked",ui.newPanel[0].id);
      },
      "activate": function(el,ui) { 
        console.log("activated",ui.newPanel[0].id);
      }
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    
    
    <div id="tabs">
      <ul>
        <li><a href="#tabs-1">Nunc tincidunt</a></li>
        <li><a href="#tabs-2">Proin dolor</a></li>
        <li><a href="#tabs-3">Aenean lacinia</a></li>
      </ul>
      <div id="tabs-1">
        <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper
          leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum.
          Nunc tristique tempus lectus.</p>
      </div>
      <div id="tabs-2">
        <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean
          aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat.
          Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
      </div>
      <div id="tabs-3">
        <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia
          nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
        <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna
          ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum.
          Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
      </div>
    </div>
    Login or Signup to reply.
  2. As far as I understand, you are using more than one jquery library as source in your code, which is exactly why one of the jquery widgets may be working and the other may not be working. So, have you checked what is the error in the console? You can use JQuery.noConflict() where you see $.
    https://api.jquery.com/jquery.noconflict/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search