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

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

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

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

mhuggins opened this issue Aug 21, 2012 · 15 comments

Comments

@mhuggins
Copy link

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.

@benbloch
Copy link

+1

@ericcf
Copy link

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
Copy link

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

@guilherme
Copy link

+1

@mhuggins
Copy link
Author

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
Copy link

ybart commented Aug 31, 2012

Workaround confirmed working. Thanks !

@amejiarosario
Copy link

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
Copy link

sewid commented Sep 2, 2012

+1

4 similar comments
@davidaragao
Copy link

+1

@pedronaves
Copy link

+1

@javjar
Copy link

javjar commented Sep 4, 2012

+1

@taylorstrait
Copy link

+1

@toadkicker
Copy link
Contributor

This should be fixed from #364

@kderbalah
Copy link

+1

@mhuggins
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests