Submit_tag 确认消息未显示确认消息
Submit_tag confirm msg is not presenting the confirm msg
我有一个 Ruby HAML 网站,我需要让用户确认他们已查看条款和条件。我正在使用 submit_tag 从购物车屏幕导航到结帐流程,并希望在结帐时收到确认消息 (submit_tag) 我的应用程序中有 = javascript_include_tag "Application" erb 文件。
我试过:确认 "I have reviewed the terms" 和
data: confirm("I have reviewed the terms") 第一次编译数据:产生语法错误。
我也试过使用 onclick
``
.row.hidden-xs.hidden-sm.visible-md.visible-lg
.col-sm-12.button-hover{:style => "text-align:right;text-size:3em;padding-right:30px"}
= submit_tag 'Checkout', :confirm => ("I have agreed to the Terms and Conditions"), :class => "btn btn-primary"
When I click Checkout it routes to the checkout page with no prompt or msg.
您的提交标签应该类似于:
<%= submit_tag "Checkout", class: "classes here", data: {confirm: "I have agreed to the Terms and Conditions"}%>
我相信 haml 它只会以 =
开头
您可以执行一个转到 javascript 函数的 onClick 事件。您需要将事件参数传递给函数。
onClickFunction(event) {
event.preventDefault;
// whatever else you want to do. Show a modal or ect.
}
preventDefault 阻止操作执行它通常执行的操作。这允许您显示提示或其他内容。在完成所有操作后,您需要绕过被阻止的操作。
文档中的更多内容:
https://apidock.com/rails/ActionView/Helpers/FormTagHelper/submit_tag
submit_tag "Save", data: { confirm: "Are you sure?" }
# => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
我有一个 Ruby HAML 网站,我需要让用户确认他们已查看条款和条件。我正在使用 submit_tag 从购物车屏幕导航到结帐流程,并希望在结帐时收到确认消息 (submit_tag) 我的应用程序中有 = javascript_include_tag "Application" erb 文件。
我试过:确认 "I have reviewed the terms" 和 data: confirm("I have reviewed the terms") 第一次编译数据:产生语法错误。 我也试过使用 onclick
`` .row.hidden-xs.hidden-sm.visible-md.visible-lg
.col-sm-12.button-hover{:style => "text-align:right;text-size:3em;padding-right:30px"} = submit_tag 'Checkout', :confirm => ("I have agreed to the Terms and Conditions"), :class => "btn btn-primary"
When I click Checkout it routes to the checkout page with no prompt or msg.
您的提交标签应该类似于:
<%= submit_tag "Checkout", class: "classes here", data: {confirm: "I have agreed to the Terms and Conditions"}%>
我相信 haml 它只会以 =
开头您可以执行一个转到 javascript 函数的 onClick 事件。您需要将事件参数传递给函数。
onClickFunction(event) {
event.preventDefault;
// whatever else you want to do. Show a modal or ect.
}
preventDefault 阻止操作执行它通常执行的操作。这允许您显示提示或其他内容。在完成所有操作后,您需要绕过被阻止的操作。
文档中的更多内容: https://apidock.com/rails/ActionView/Helpers/FormTagHelper/submit_tag
submit_tag "Save", data: { confirm: "Are you sure?" }
# => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />