link_to :confirm displays popup twice

后端 未结 16 1852
感情败类
感情败类 2020-11-30 02:38

This tag with rails 3

<%= link_to \'Destroy\', item, :method => :delete,:confirm=>\'Are you sure?\' %>

produces this html

相关标签:
16条回答
  • 2020-11-30 03:28

    It sounds like the confirmation handler Javascript in rails.js is being attached twice.

    Could you be accidentally including two copies of rails.js via duplication of a javascript_include_tag helper?

    0 讨论(0)
  • 2020-11-30 03:29

    In my case jQuery was loaded twice because of the line //= require_tree .

    To prevent this error in application.js and application.css I'm used to create a subdirectory app/assets/javascript/autorequire and instead of require_tree . I do require_tree ./autorequire.

    So, files in app/assets/javascript and app/assets/stylesheets are not included automatically/accidentally anymore. I put all my individual .css and .js files into the subdirectory and they are included implicitly. But I can define which files from the top-path are to be included and in which order.

    Since I do so, I never had troubles by assets not loaded as I expect them to be.

    0 讨论(0)
  • I'm using Rails 4 and none of the answers worked for me, however the following worked... I changed the line:

    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 
    

    to

    <%= javascript_include_tag 'application', 'data-turbolinks-eval' => false %>.
    

    https://github.com/rails/turbolinks/issues/244

    0 讨论(0)
  • 2020-11-30 03:33

    I've had the same problem with Rails 3.2.12, but simply updating to 3.2.13 solved that problem for me.

    0 讨论(0)
  • 2020-11-30 03:35

    In my case, it was that the application had both "mootools ujs" and "jquery ujs" included. I got rid of the mootools one and now I only see one confirmation.

    0 讨论(0)
  • 2020-11-30 03:35

    In the layout haml like this have the twice pop up problem

    %head
      = stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload'
      = javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
    %body
      #calendar.calendarsize
    

    Then I commend it and it works.

    %head
      = stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload'
      -#= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
    %body
      #calendar.calendarsize
    
    0 讨论(0)
提交回复
热议问题