Rails 替换 confirm with Zurb 基础模态 - Uncatch TypeError: confirm
Rails replace confirm with Zurb foundation modal - Uncaught TypeError: confirmWithReveal is not a function
让我先说,我不擅长javascript。如果我错过了一些明显的东西,请原谅我。
我想将标准确认对话框替换为基础模式对话框。有人可以帮助我在页面中构建正确的结构吗?我在index.html.erb页面上有以下link_to:
<%= link_to 'Delete', post, method: :delete, data: { confirm: "Are you sure?" }, class: "tiny radius button" %>
我注意到当页面加载时,我在控制台中收到一个错误:
Uncaught TypeError: $(...).confirmWithReveal is not a function
此错误似乎出现在每个页面上。我明确定义的模式对话框适用于其他页面。
我做了一些研究,找不到任何明确的例子来说明如何做到这一点。此页显示了确认的各种样式,但不显示如何在 <%= link_to ... %> 表达式中使其工作。
confirm_with_reveal不是Foundation的一部分,而是一个额外的模块。以下是我使用它的步骤:
- 放置来自 GitHub 存储库的源文件之一,例如
confirm_with_reveal.js
到您的 rails 的vendor/assets/javascripts/confirm_with_reveal.js
文件夹中。通常我将存储库添加为子模块,但这取决于您。 -
添加到
app/assets/javascripts/application.js
//= require jquery //= require jquery_ujs //= require confirm_with_reveal/confirm_with_reveal $(function(){ $(document).confirmWithReveal(); });
-
重写您的标准导轨确认自
link_to 'Delete', post, method: :delete, data: { confirm: "Are you sure?" }, class: "tiny radius button" %>
自
link_to 'Delete', post, method: :delete, data: { confirm: {title:"Are you sure?"} }, class: "tiny radius button" %>
并尝试使用您在自述文件中找到的属性。
-
此外,如果您使用 foundation 6,则必须修改 javascript 并在第 54 行中替换:
modal.foundation('reveal', 'close');
跟
modal.foundation('close');
在第 68 行:
foundation('reveal', 'open')
跟
foundation('open')
相关文章:
- javascript confirm()ok和cancel返回相同的结果
- Angular Material$mdDialog.confirm;OK”;以及“;取消“;选项
- Opera Mini是否支持window.confirm()
- Javascript使用Confirm取消表单提交
- 包含ng模板的指令中的角度transclude(通用Confirm Modal)
- 我收到此错误Uncatch TypeError:this.getElements不是一个函数
- 如何获取jQuery Confirm(jConfirm)值并使用该值检查条件
- 使用confirm从按钮中的javascript停止angular
- confirm() on window.onbeforeunload
- javascript confirm()取消导航
- alert()和confirm()未显示在iframe的父级上
- Ember cli Uncatch TypeError: undefined 不是函数
- jQuery.ajax Uncatch SyntaxError: 意外标识符
- cordova 2.0.0 给出了 Uncatch TypeError:对象 0 没有方法 'func'
- Infragistics igGrid Uncatch TypeError: undefined 不是一个函数
- Uncatch TypeError:DB.find 不是 React with Meteor 1.3 中的函数
- jQuery after() uncatch SyntaxError: 意外令牌 ILLEGAL
- 如何自定义数据::confirm弹出窗口以提示输入,该输入将附加到请求参数中
- 使用Laravel Form的Jquery Confirm不起作用
- Rails 替换 confirm with Zurb 基础模态 - Uncatch TypeError: confirm