保存数据之前实现模态
我正在开发一个应用程序,管理员可以在其中向公众发布欢迎消息。 基本上,在发布“发布到公共页面”后,我需要在发布消息之前实现模式,该警告说“您将在公共状态页面上将此内容发布给世界。所有互联网用户都可以看到它,而不仅仅是您的同事。单击“确定”以发布或“取消”以返回。
在我单击发布的阶段,直接保存了欢迎消息时,我在显示模式时遇到了困难。
这是我的代码:
<div class="row" id="notice-edit-container" style="display: none;">
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-content">
<i><%= t('statusx.guide_text')%></i><br />
<form accept-charset="UTF-8" class="message-form" action="<%= public_page_path %>" method="post" data-image-path="<%= upload_image_noticeboards_path %>">
<textarea class="noticeEditor" name="content" style="width: 100%; height:340px;">
<%= @welcome_message %>
</textarea>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<%= hidden_field_tag :_method, "put" %>
<%= t('statusx.public_page_link')%>
<%= link_to "https://demo.getvetter.com/public", target: :_blank %>
<br>
<br>
<button type="submit"
class="btn btn-primary tn-w-m"
data-toggle="modal"
data-target="#approvalMessageModal">
<%= t('statusx.save') %></button>
<button id="cancel_submit" class="btn btn-default btn-w-m"><%= t('cancel') %></button>
</form>
</div> <!-- end ibox-content -->
</div> <!-- end ibox -->
</div>
</div>
<!-- Modal -->
<div id="approvalMessageModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="approvalMessageModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p><%= t('statusx.popup.warning') %></p>
</div>
<div class="modal-footer">
<button type="button" class="notice-read-ok btn btn-primary btn-block" data-dismiss="modal"><%= t('ok') %></button>
<button id="cancel_submit" class="btn btn-default btn-w-m"><%= t('cancel') %></button>
</div>
</div>
// Warning modal before publish welcome message
$(document).ready(function () {
$('#approvalMessageModal').modal('show');
});
我很感谢您的帮助显示模式并保存数据。 多谢
I am working on an app where Admin can publish a welcome message to the public.
I need to implement a modal before Publishing the message, basically, after they click ‘Publish to Public page’ show a warning which says “You are about to publish this content to the world, on your public status page. It will be visible to all internet users, not just your colleagues. Click ‘OK’ to publish or ‘Cancel’ to go back.
At the stage when I click on publish this directly saves the welcome message, I am having trouble displaying the modal.
Here is my code:
<div class="row" id="notice-edit-container" style="display: none;">
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-content">
<i><%= t('statusx.guide_text')%></i><br />
<form accept-charset="UTF-8" class="message-form" action="<%= public_page_path %>" method="post" data-image-path="<%= upload_image_noticeboards_path %>">
<textarea class="noticeEditor" name="content" style="width: 100%; height:340px;">
<%= @welcome_message %>
</textarea>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<%= hidden_field_tag :_method, "put" %>
<%= t('statusx.public_page_link')%>
<%= link_to "https://demo.getvetter.com/public", target: :_blank %>
<br>
<br>
<button type="submit"
class="btn btn-primary tn-w-m"
data-toggle="modal"
data-target="#approvalMessageModal">
<%= t('statusx.save') %></button>
<button id="cancel_submit" class="btn btn-default btn-w-m"><%= t('cancel') %></button>
</form>
</div> <!-- end ibox-content -->
</div> <!-- end ibox -->
</div>
</div>
<!-- Modal -->
<div id="approvalMessageModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="approvalMessageModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p><%= t('statusx.popup.warning') %></p>
</div>
<div class="modal-footer">
<button type="button" class="notice-read-ok btn btn-primary btn-block" data-dismiss="modal"><%= t('ok') %></button>
<button id="cancel_submit" class="btn btn-default btn-w-m"><%= t('cancel') %></button>
</div>
</div>
// Warning modal before publish welcome message
$(document).ready(function () {
$('#approvalMessageModal').modal('show');
});
I would appreciate help to display the modal and save data.
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从表单内的按钮中删除提交类型,然后单击按钮弹出模式框。
并在模态框中的确定按钮的动作上提交表格。
我尚未测试代码。希望这会给您一个主意。
Remove the submit type from the button inside the form and on the click of the button popup the modal box.
And on the action of ok button inside modal box submit the form.
I have not tested the code. Hope this will give you an idea.