Twitter Bootstrap模式rails删除按钮不起作用

我转而使用Twitter Bootstrap 2.1.1。

我有一个模式有一个删除按钮,但它不起作用。 在以前的bootstrap版本中它运行正常。 Rails版本是3.1

这是代码

<a title="" id="delete" class="label" href="#myModal-" data-toggle="modal"> 

模态

 <div class="modal hide" id="myModal-" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">    

但它不起作用。 Rails接收GET并显示post,但它不会破坏它。

任何的想法? 谢谢

我在http://rors.org/demos/custom-confirm-in-rails上找到了以下解决方案

您可以完全不显眼地使用它,而无需在视图中使用自定义删除链接或模态内容。 所以在我看来,我有标准的Rails链接(只添加一些类来使用Bootstrap样式):

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

以及/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 = """  """ $(html).modal() $('#confirmationDialog .confirm').on 'click', -> $.rails.confirmed(link) 

如果您想在模式中添加更多post特定的详细信息,您可以随时将它们作为数据属性包含在删除链接中(就像data-confirm用于显示确认消息一样。)