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

Is it possible to make the parent clickable #27

Closed
SmashBrando opened this issue Aug 16, 2013 · 6 comments
Closed

Is it possible to make the parent clickable #27

SmashBrando opened this issue Aug 16, 2013 · 6 comments

Comments

@SmashBrando
Copy link

One issue I run into with clients is they always want the menu to work on hover, and for the parent to be clickable. For example about use - /about/ and then sub pages below that like contact, history, etc...

This would be similar to how superfish menu works.

@CWSpear
Copy link
Collaborator

CWSpear commented Aug 19, 2013

Right, my plugin should let you do that... let me do some double checking (sorry for the slower response. Been out of town).

What happened when you tried it? You aren't actually stating an issue here.

@SmashBrando
Copy link
Author

The issue is that the parent element does not link anywhere it only acts as a label (even though it has an href).

You can see an example here (try clicking "About The Tests") - http://11thstreetmedia.net/

@CWSpear
Copy link
Collaborator

CWSpear commented Aug 19, 2013

Sorry, after looking deeper, some things came back to my memory. This is a duplicate of case #16. Bootstrap is preventing the default action for those nav items. If you want them to be clickable, you'll have to figure out a way to get around that, but it's something outside the scope of my plugin.

@leniel
Copy link

leniel commented Oct 6, 2013

I'm using Bootstrap 3 now and to make the root node clickable I just returned true instead of false in the following bootstrap.js Dropdown toogle function but be aware that I didn't test this extensively... :)

Dropdown.prototype.toggle = function (e) {
    var $this = $(this)

    if ($this.is('.disabled, :disabled')) return

    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')

    clearMenus()

    if (!isActive) {
      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
        // if mobile we we use a backdrop because click events don't delegate
        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
      }

      $parent.trigger(e = $.Event('show.bs.dropdown'))

      if (e.isDefaultPrevented()) return

      $parent
        .toggleClass('open')
        .trigger('shown.bs.dropdown')

      $this.focus()
    }

    return true;
  }

@CWSpear
Copy link
Collaborator

CWSpear commented Oct 12, 2013

Issue #16 was the solution under Bootstrap 2. I think it still applies because I think the function you pasted in here is bound to a click event. The reason returning true in your snippet works is because returning false in a jQuery event callback stops all propagation, including the default behavior of the current event. By returning true, you allow the event to behave normally.

Just be aware on the effect this will have on mobile users (if that's even a concern of yours).

@leniel
Copy link

leniel commented Oct 12, 2013

Yeah... it's working great with Bootstrap 3. I tested it on an iPhone and
the touch works as expected.

On Friday, October 11, 2013, Cameron Spear wrote:

Issue #16https://github.com/CWSpear/twitter-bootstrap-hover-dropdown/issues/16was the solution under Bootstrap 2. I think it still applies because I
think the function you pasted in here is bound to a click event. The reason
returning true in your snippet works is because returning false in a jQuery
event callback stops all propagation, including the default behavior of the
current event. By returning true, you allow the event to behave normally.

Just be aware on the effect this will have on mobile users (if that's even
a concern of yours).


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-26189523

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

3 participants