gpt4 book ai didi

ruby-on-rails - 为什么确认 rails button_to helper 的选项不起作用

转载 作者:行者123 更新时间:2023-12-04 07:29:04 24 4
gpt4 key购买 nike

我有一个 rails button_to,我希望它在继续之前显示一个确认对话框。

<%= button_to("Rebuild indexes", action: "rebuild_indexes", data:
{confirm: "Are you sure you want to reset the indexes?" }) %>

操作正在发生,但我没有收到确认框。我读到这个问题可能与javascript有关。我以为我已经启用了。
application.js
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require turbolinks
//= require tinymce-jquery
//= require ckeditor/init
//= require ckeditor/config.js
//= require jquery.are-you-sure
//= require script
//= require script.responsive
//= require_tree .

如果我对按钮进行检查,我会看到
<form class="button_to" method="post" action="/help/rebuild_indexes?data%5Bconfirm%5D=Are+you+sure+you+want+to+reset+the+indexes%3F">
<input type="submit" value="Rebuild indexes">
<input type="hidden" name="authenticity_token" value="3mnAMmyHaINiDngjQn87EMmhmetp2VJcX+lwcmbUlhwBfv7V1hpLc9ZY1OF5JAFm9erFJjX+qyDz35/KK41jaA==">
</form>

出现确认框时我缺少什么?

最佳答案

我在以下行中遇到了类似的问题:

 <%= button_tag 'Delete', onclick: "location.href = #{polymorphic_url(obj)}", :method => :delete, type: 'button', class: 'btn btn-danger', title: 'Delete', id: 'delete_btn', data: { confirm: 'Are you sure you want to delete this record?' } %>

删除“type: 'button'”修复了确认提示问题

关于ruby-on-rails - 为什么确认 rails button_to helper 的选项不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35043385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com