Git Product home page Git Product logo

Comments (7)

CWSpear avatar CWSpear commented on June 9, 2024

That active class is certainly added by the system when the page is rendered and then there is CSS to make that active class appear, and then styles to make it look different.

I don't understand the other part... you want to show menus as "open" by default if they are active? Why? Wouldn't that cover up some of the page?

In terms of adding a class to the <li>, you could do something like this in PHP ($currentLink is a variable you set possibly from a $_SERVER variable):

<li class="<?= $currentLink == '/about/' ? 'active' : '' ?>"><a href="/about/">About</a></li>

or same example but using AngularJS (currentLink is something set from $location, i.e. $scope.currentLink = $location.path()):

<li ng-class="{ active: currentLink == '/about/' }"><a href="/about/">About</a></li>

from bootstrap-hover-dropdown.

abombelli avatar abombelli commented on June 9, 2024

Thanks for the feedback!

The part of setting the corresponding class to the

  • is not the problem.

    Let me elaborate, just looking at the top level list. I'll not include the submenu code.

    Lets assume we have a list:

    <u class="nav navbar-nav">
    <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-target="#" href="/products/">Products</a></li>
    <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-target="#" href="/about/">About</a></li>
    <ul>

    Now, we access the page "About", then it looks like this:

    <u class="nav navbar-nav">
    <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-target="#" href="/products/">Products</a></li>
    <li class="dropdown active"><a class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-target="#" href="/about/">About</a></li>
    <ul>

    active is added to the list tag.

    This entry has is own css style, so it is visible for the user where he is.
    Now using your plugin, by hovering over "Products", the class open is added to the products entry.
    The result is, I have two highlighted entries.

    What I try to achieve is to remove the active class temporarily, as long the user hovers over other menu entries. When the hover is done, the active class should be added again.

    Another approach is to add ann additional class to the active list tag, while hovering, and remove it as soon the hover over the other entries is finished.

    Hope this makes sense.

  • from bootstrap-hover-dropdown.

    CWSpear avatar CWSpear commented on June 9, 2024

    I think so, but why not use separate styles for active? There's no reason it shouldn't always show the active state, even if they're hovering over other items. For example, Bootstrap even has an active class, and it highlights the item blue, and the hover styles are light grey (in this screenshot, I'm hovering over the 2nd to bottom item and the top one is "active"):

    menu screenshot

    from bootstrap-hover-dropdown.

    abombelli avatar abombelli commented on June 9, 2024

    I just setup an example here: http://www.bootply.com/RbT27Dlej6
    As you can see, the "Dropdown" submenu is active and the submenu visible; fine.
    But when I hover over "Contact", the "Dropdown" submenu remains, but should hide while hovering over "Contact".

    from bootstrap-hover-dropdown.

    CWSpear avatar CWSpear commented on June 9, 2024

    This issue isn't with my plugin but with the other plugin you're using. You could make the background a solid for the submenu and then have the submenu have a higher z-index than the active and be done. You could fix this all with tweaking a couple lines of CSS on the other plugin.

    from bootstrap-hover-dropdown.

    abombelli avatar abombelli commented on June 9, 2024

    Ok. Another approach without interfering any other plugins.
    I'm just using your demo page: When the entry "Dropdown" has the class active, while hovering over "Account", how can I disable the active status for this time?

    from bootstrap-hover-dropdown.

    CWSpear avatar CWSpear commented on June 9, 2024

    You would have to mess with my plugin. And it would require changing the JavaScript whereas the other plugin only requires you putting some styles in your own stylesheet.

    You'd have to create a index of elements with active on them and take them off/put them back depending on if other menu items are open. It will be tricky, but you're welcome to fork and do that. It's not something I think needs to belong in this plugin tho.

    from bootstrap-hover-dropdown.

    Related Issues (20)

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.