Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:37:15+00:00 2026-06-11T08:37:15+00:00

I am switching to Twitter Bootstrap 2.1.1. I have a modal with a button

  • 0

I am switching to Twitter Bootstrap 2.1.1.

I have a modal with a button to delete but it does not work. In previous bootstrap version it worked OK. Rails version is 3.1

Here is the code

<a title="<%= t('delete') %>" id="delete" class="label" href="#myModal-<%= post.id %>" data-toggle="modal"><%= t('delete') %></a>

the modal

<div class="modal hide" id="myModal-<%= post.id %>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel"><%= t('delete_this_question') %></h3>
    </div>
    <div class="modal-body">
        <p><%= raw post.text %></p>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true"><%= t('cancel') %></button>
        <%= link_to(t('delete'), { :controller => 'posts', :action => 'destroy', :id => post.id } ,:method => :delete, :class => 'btn btn-primary') %>
    </div>
</div>

But it does not work. Rails receives a GET and shows the post, but it does not destroy it.

Any idea? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:37:17+00:00Added an answer on June 11, 2026 at 8:37 am

    I found the following solution on http://rors.org/demos/custom-confirm-in-rails

    You can use this completely unobtrusively without having to have a custom delete link or modal content in your view. So in my view I have the standard Rails link (only adding some classes to use the Bootstrap styles):

    link_to 'delete', post, method: :delete, confirm: 'Are you sure?', class: 'btn btn-mini btn-danger'
    

    And the following in /app/assets/javascripts/bootstrap-confirmation.js.coffee

    $.rails.allowAction = (link) ->
      return true unless link.attr('data-confirm')
      $.rails.showConfirmDialog(link) # look bellow for implementations
      false # always stops the action since code runs asynchronously
    
    $.rails.confirmed = (link) ->
      link.removeAttr('data-confirm')
      link.trigger('click.rails')
    
    $.rails.showConfirmDialog = (link) ->
      message = link.attr 'data-confirm'
      html = """
             <div class="modal" id="confirmationDialog">
               <div class="modal-header">
                 <a class="close" data-dismiss="modal">&times;</a>
                 <h3>Request confirmation</h3>
               </div>
               <div class="modal-body">
                 <p>#{message}</p>
               </div>
               <div class="modal-footer">
                 <a data-dismiss="modal" class="btn">Cancel</a>
                 <a data-dismiss="modal" class="btn btn-danger confirm">Confirm</a>
               </div>
             </div>
             """
      $(html).modal()
      $('#confirmationDialog .confirm').on 'click', -> $.rails.confirmed(link)
    

    If you want more post specific details in your modal you can always include them as data- attributes in your delete link (just like data-confirm is used to display the confirmation message.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to have something in my app that is just like Twitter but
After switching to Rails 3, I noticed that I have to reboot my server
I'm trying to get the twitter on page tabbed content to work. I have
I have an application that I am switching to bootstrap. All of the design
I just upgraded the gem less-rails-bootstrap to use twitter bootstrap 2.1.0, and it seems
Does switching activities in Android start a fresh JVM? It seems like each activity
After switching to a new mac at work, I tried to install APC as
I need your help. I have been switching from various libraries trying to find
Switching to RightToLeft (by altering MainWindow.FlowDirection) changes strings which have a round (closing) paranthesis
Switching from Microsofts Oracle Driver to ODP.NET version 10.2.0.100. After changing the data types

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.