Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open submenu on hover instead of click #13

Open
nikolas opened this issue Jul 16, 2015 · 14 comments
Open

Open submenu on hover instead of click #13

nikolas opened this issue Jul 16, 2015 · 14 comments

Comments

@nikolas
Copy link

nikolas commented Jul 16, 2015

How do I use bootstrap-submenu to open the submenu on hover? That's how bootstrap 2 did it: http://getbootstrap.com/2.3.2/components.html#dropdowns

@alvarotrigo
Copy link

+1

2 similar comments
@artrz
Copy link

artrz commented Nov 13, 2015

+1

@Rajiv-Kulkarni
Copy link

+1

@upupzealot
Copy link

+1 Any one find a solution?

@davidsellen
Copy link

+1

1 similar comment
@top-kat
Copy link

top-kat commented Jun 12, 2016

+1

@top-kat
Copy link

top-kat commented Jun 12, 2016

Hi, my friends, I 've found a solution !
And don't forget that if you want to make link clickable, you have to remove data-toggle="dropdown" from html

Just replace the function from line 67 to env. 110 by this one

$.extend(SubmenuItem.prototype, Item.prototype, {
    init: function() {
      this.$element.on({
        click: $.proxy(this, 'click'), // you can disable former click event here
        keydown: $.proxy(this, 'keydown'),
    mouseover: $.proxy(this, 'mouseover') //support for mouseover
      });
      this.$main.on('hide.bs.submenu, mouseleave', $.proxy(this, 'hide')); // added mouseleave for menu to reset when mouse leaves
    },
    click: function(event) { // you can disable former click event here
      // Fix a[href="#"]. For community
      /*event.preventDefault();

  event.stopPropagation();

  this.toggle();*/
},
mouseover: function(event) { // added mouseover function
  this.open();
},
hide: function(event) {
  // Stop event bubbling
  event.stopPropagation();

  this.close();
},
open: function() {
  this.$main.addClass('open');
  this.$subs.trigger('hide.bs.submenu');
},
toggle: function() {
  if (this.$main.hasClass('open')) {
    this.close();
  }
  else {
    this.open();
  }
},
keydown: function(event) {
  // 13: Return, 32: Spacebar

  if (event.keyCode == 32) {
    // Off vertical scrolling
    event.preventDefault();
  }

  if ($.inArray(event.keyCode, [13, 32]) != -1) {
    this.toggle();
  }
}

  });

Also a big thanks to @vsn4ik for this very light and effective plug-in !

Hope this helps

@eduardelatorre
Copy link

+1

@Martchus
Copy link

Martchus commented Nov 8, 2016

+1

@macsplan
Copy link

macsplan commented Mar 1, 2017

Thanks @myrmecia done that, here's my gist of the change: https://gist.github.com/macsplan/39c29d44ff5fd0b18d6699087f0a1874

Still opening on hover, any ideas where i'm going wrong?

@Martchus
Copy link

Martchus commented Mar 1, 2017

This is the modification to show the menu on mouseover I created for openQA some time ago: Martchus@2816257

We decided to stick with the on-click-version after all, but I tested it and it worked.

@macsplan
Copy link

macsplan commented Mar 1, 2017

thanks @Martchus do you have the code for the click-only version?

@Martchus
Copy link

Martchus commented Mar 1, 2017

The version in this repository is the click-only version. At least release v2.0.4 which we use in openQA.

@macsplan
Copy link

macsplan commented Mar 1, 2017

thanks @Martchus, must have a problem in my app. will figure it out, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants