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

data-method links don't work under nav dropdowns #343

Closed
mhuggins opened this Issue Aug 21, 2012 · 15 comments

Comments

Projects
None yet
@mhuggins

mhuggins commented Aug 21, 2012

It appears that data-method links (specifically for a :delete action to destroy a session) does not work as part of a navigation link within ul.dropdown-menu. If I copy the link code verbatim into the navigation itself (i.e.: it appears under ul.nav), then the link works perfectly fine.

The issue is only occurring when using twitter-bootstrap-rails from git master HEAD (specifically ref efc2fdc139f9, which includes the update for Twitter Bootstrap v2.1.0). If I switch back to twitter-bootstrap-rails version 2.1.1, then the issue goes away.

I've included relevant code below.

Gemfile

gem 'rails', '3.2.8'
gem 'jquery-rails'
gem 'devise'
gem 'therubyracer'
# gem 'twitter-bootstrap-rails', '2.1.1'                                    # this version works
gem 'twitter-bootstrap-rails', github: 'seyhunak/twitter-bootstrap-rails'   # this version fails

routes.rb

devise_for :users

layouts/application.html.haml

.container.nav-collapse
  -if user_signed_in?
    %ul.nav.pull-right
      -# This link works:
      %li= link_to 'Logout', destroy_user_session_path, method: :delete
      %li.dropdown
        %ul.dropdown-menu
          -# This link fails:
          %li= link_to 'Logout', destroy_user_session_path, method: :delete

The specific routing error message is:

No route matches [GET] "/users/sign_out"

Apparently something in twitter-bootstrap-rails is preventing jquery-rails from processing the data-method="delete" attribute correctly on ONLY the dropdown menu version of the link.

@benbinary

This comment has been minimized.

Show comment
Hide comment
@benbinary

benbinary commented Aug 23, 2012

+1

@ericcf

This comment has been minimized.

Show comment
Hide comment
@ericcf

ericcf Aug 23, 2012

It's true for other methods such as :put too, and it seems to be a bootstrap issue: twbs/bootstrap#4497

ericcf commented Aug 23, 2012

It's true for other methods such as :put too, and it seems to be a bootstrap issue: twbs/bootstrap#4497

@cebartling

This comment has been minimized.

Show comment
Hide comment
@cebartling

cebartling Aug 23, 2012

I'm seeing similar issues with the nav dropdown with regular links. Probably connected to twbs/bootstrap#4497 issue.

cebartling commented Aug 23, 2012

I'm seeing similar issues with the nav dropdown with regular links. Probably connected to twbs/bootstrap#4497 issue.

@guilherme

This comment has been minimized.

Show comment
Hide comment
@guilherme

guilherme commented Aug 25, 2012

+1

@mhuggins

This comment has been minimized.

Show comment
Hide comment
@mhuggins

mhuggins Aug 26, 2012

User mfansler provided a workaround in the other issue, which works when I add it to my application.js.

$('body')
  .off('click.dropdown touchstart.dropdown.data-api', '.dropdown')
  .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() });

Not ideal, but will work until Bootstrap 2.1.1 is released.

mhuggins commented Aug 26, 2012

User mfansler provided a workaround in the other issue, which works when I add it to my application.js.

$('body')
  .off('click.dropdown touchstart.dropdown.data-api', '.dropdown')
  .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() });

Not ideal, but will work until Bootstrap 2.1.1 is released.

@ybart

This comment has been minimized.

Show comment
Hide comment
@ybart

ybart Aug 31, 2012

Workaround confirmed working. Thanks !

ybart commented Aug 31, 2012

Workaround confirmed working. Thanks !

@amejiarosario

This comment has been minimized.

Show comment
Hide comment
@amejiarosario

amejiarosario Sep 1, 2012

I tried the workaround but didn't work! So, I just went back to v2.1.0 and it's working again!
gem "twitter-bootstrap-rails", '=2.1.0', :group => :assets

amejiarosario commented Sep 1, 2012

I tried the workaround but didn't work! So, I just went back to v2.1.0 and it's working again!
gem "twitter-bootstrap-rails", '=2.1.0', :group => :assets

@sewid

This comment has been minimized.

Show comment
Hide comment
@sewid

sewid commented Sep 2, 2012

+1

@davidaragao

This comment has been minimized.

Show comment
Hide comment
@davidaragao

davidaragao commented Sep 3, 2012

+1

@pedronaves

This comment has been minimized.

Show comment
Hide comment
@pedronaves

pedronaves commented Sep 4, 2012

+1

@javjar

This comment has been minimized.

Show comment
Hide comment
@javjar

javjar commented Sep 4, 2012

+1

@taylorstrait

This comment has been minimized.

Show comment
Hide comment
@taylorstrait

taylorstrait commented Sep 6, 2012

+1

@toadkicker

This comment has been minimized.

Show comment
Hide comment
@toadkicker

toadkicker Sep 6, 2012

Contributor

This should be fixed from #364

Contributor

toadkicker commented Sep 6, 2012

This should be fixed from #364

@kderbalah

This comment has been minimized.

Show comment
Hide comment
@kderbalah

kderbalah commented Sep 17, 2012

+1

@mhuggins mhuggins closed this Sep 17, 2012

@mhuggins

This comment has been minimized.

Show comment
Hide comment
@mhuggins

mhuggins Sep 17, 2012

Thanks for the update, @toadkicker. I've gone ahead and closed this issue.

mhuggins commented Sep 17, 2012

Thanks for the update, @toadkicker. I've gone ahead and closed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment