- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的一个 View 中,我有以下 html 来用数据库中的数据(从 View Controller 传递)填充一个表,并在每一行上包含一个按钮,该按钮打开一个弹出模式,其中包含有关的更多信息项目是这样的。
我的 index.blade.php:
@extends('layouts.app')
@section('style')
<style>
.panel-pagination {
margin: 0 0 !important;
}
.panel-container {
padding-right: 0 !important;
padding-left: 0 !important;
height:35px;
}
.abc {
height:35px;
display:table-cell !important;
vertical-align:middle;
}
.link-btn,
.link-btn:visited,
.link-btn:link,
.link-btn:active {
color: #3196D6;
background: #fff;
padding: 10px 20px;
display: block;
text-align: center;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 13px;
}
.link-btn:hover {
background: #E7E7E7;
}
</style>
@endsection
@section('content')
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-container">
<div class="col-xs-12 col-sm-6 col-lg-8 text-left">
<h4 class="panel-title abc">
<i class="glyphicon glyphicon-hdd"></i>
Machine Configurator
</h4>
</div>
<-- some html stuff -->
</div>
</div>
<div class="panel-body">
<table class="table table-striped table-bordered" id="machineTable">
<thead>
<-- some table header stuff -->
</thead>
<tbody>
@foreach($machines as $key => $value)
<tr>
<td>{{ $value->machineName }}</td>
<td>{{ $value->departmentName }}</td>
<td>{{ $value->partName }} {{ $value->partRevision }}</td>
<td>{{ $value->productionStatus }}</td>
<td>
<a class="btn btn-small btn-success" href="{{ URL::to('machine/' . $value->machineId) }}"
data-toggle="modal"
data-target="#showMachinePopupModal">
<!-- Info -->
<i class="glyphicon glyphicon-info-sign"></i>
</a>
<-- some more buttons -->
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div id="showMachinePopupModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
@endsection
@section('script')
<script>
$(document).ready(function() {
$("#showMachinePopupModal").on("hidden.bs.modal", function() {
$("#showMachinePopupModal .modal-content").empty();
});
});
</script>
@endsection
问题是我不知道如何在模态关闭时清除模态内容。因此,除非用户刷新页面,否则当用户点击查看某个item的更多信息后,modal中始终显示相同的数据。我尝试了以下 javascript,但它们似乎不起作用。
$('#showMachinePopupModal').on('hidden.bs.modal', function () {
$('.modal-content').html("");
});
$('#showMachinePopupModal').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});
我正在使用 Laravel 的资源 Controller 。这是我的“show.blade.php”
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">X</button>
<h2 class="modal-title text-center">#{{ $machine->machineId }} - {{ $machine->machineName }}</h2>
</div>
<div class="modal-body">
<p>
<strong>Type:</strong> {{ $machine->machineType }}<br>
<strong>Department:</strong> {{ $machine->departmentName }}<br>
<strong>Production Status:</strong> {{ $machine->productionStatus }}<br>
<strong>Quality Status:</strong> {{ $machine->qualityStatus }}<br>
<strong>Part Loaded:</strong> {{ $machine->partName }} {{ $machine->partRevision }}<br>
<strong>Last Updated:</strong> {{ $machine->updatedAt }}<br>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
这是我的 app.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'SEI-MQE') }}</title>
<!-- Styles -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp"
crossorigin="anonymous">
<!-- <link href="{{ asset('css/app.css') }}" rel="stylesheet"> -->
@yield('style')
</head>
<body>
@include('include.navigationBar')
@include('include.flashMessage')
@yield('content')
@yield('modal')
<!-- Scripts -->
<!-- <script src="{{ asset('js/app.js') }}"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js"></script>
@yield('script')
</body>
</html>
解决方案:通过遵循 Nikolas 的解决方案但使用此脚本清除来修复:
$(document).ready(function() {
$('#showMachinePopupModal').on('hidden.bs.modal', function () {
$(this).removeData();
});
});
最佳答案
试试这个:
$(document).ready(function() {
$("#showMachinePopupModal").on("hidden.bs.modal", function() {
$("#showMachinePopupModal .modal-content").empty();
});
});
更新
尝试在您的模式中添加它。像这样:
<div id="showMachinePopupModal" tabindex="-1" role="dialog" aria-hidden="true" class="modal fade">
也尝试移动模态 div,使其位于任何具有特殊定位的元素之外。一个好的地方可能就在结束的 body 标签之前 </body>
更新 2尝试在 app.blade.php 和 index.blade.php 中为模态创建另一个 yield 添加:
@section('modal-forms')
PUT YOUR MODAL HERE
@stop
同时在你的 app.blade.php 中添加 bootstrap.js
关于javascript - Laravel - 如何清除打开远程 View 的引导模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45624425/
对此感到疯狂,真的缺少一些东西。 我有webpack 4.6.0,webpack-cli ^ 2.1.2,所以是最新的。 在文档(https://webpack.js.org/concepts/mod
object Host "os.google.com" { import "windows" address = "linux.google.com" groups = ["linux"] } obj
每当我安装我的应用程序时,我都可以将数据库从 Assets 文件夹复制到 /data/data/packagename/databases/ .到此为止,应用程序工作得很好。 但 10 或 15 秒后
我在 cc 模式缓冲区中使用 hideshow.el 来折叠我不查看的文件部分。 如果能够在 XML 文档中做到这一点就好了。我使用 emacs 22.2.1 和内置的 sgml-mode 进行 xm
已结束。此问题不符合 Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等方面的建议的问题。您可以编辑问题,以便用事实和引用来回答它。 关闭
根据java: public Scanner useDelimiter(String pattern) Sets this scanner's delimiting pattern to a patt
我读过一些关于 PRG 模式以及它如何防止用户重新提交表单的文章。比如this post有一张不错的图: 我能理解为什么在收到 2xx 后用户刷新页面时不会发生表单提交。但我仍然想知道: (1) 如果
看看下面的图片,您可能会清楚地看到这一点。 那么如何在带有其他一些 View 的简单屏幕中实现没有任何弹出/对话框/模式的微调器日期选择器? 我在整个网络上进行了谷歌搜索,但没有找到与之相关的任何合适
我不知道该怎么做,我一直遇到问题。 以下是代码: rows = int(input()) for i in range(1,rows): for j in range(1,i+1):
我想为重写创建一个正则表达式。 将所有请求重写为 index.php(不需要匹配),它不是以/api 开头,或者不是以('.html',或'.js'或'.css'或'.png'结束) 我的例子还是这样
MVC模式代表 Model-View-Controller(模型-视图-控制器) 模式 MVC模式用于应用程序的分层开发 Model(模型) - 模型代表一个存取数据的对象或 JAVA PO
我想为组织模式创建一个 RDF 模式世界。您可能知道,组织模式文档基于层次结构大纲,其中标题是主要的分组实体。 * March auxiliary :PROPERTIES: :HLEVEL: 1 :E
我正在编写一个可以从文件中读取 JSON 数据的软件。该文件包含“person”——一个值为对象数组的对象。我打算使用 JSON 模式验证库来验证内容,而不是自己编写代码。符合代表以下数据的 JSON
假设我有 4 张 table 人 公司 团体 和 账单 现在bills/persons和bills/companys和bills/groups之间是多对多的关系。 我看到了 4 种可能的 sql 模式
假设您有这样的文档: doc1: id:1 text: ... references: Journal1, 2013, pag 123 references: Journal2, 2014,
我有这个架构。它检查评论,目前工作正常。 var schema = { id: '', type: 'object', additionalProperties: false, pro
这可能很简单,但有人可以解释为什么以下模式匹配不明智吗?它说其他规则,例如1, 0, _ 永远不会匹配。 let matchTest(n : int) = let ran = new Rand
我有以下选择序列作为 XML 模式的一部分。理想情况下,我想要一个序列: 来自 my:namespace 的元素必须严格解析。 来自任何其他命名空间的元素,不包括 ##targetNamespace和
我希望编写一个 json 模式来涵盖这个(简化的)示例 { "errorMessage": "", "nbRunningQueries": 0, "isError": Fals
首先,我是 f# 的新手,所以也许答案很明显,但我没有看到。所以我有一些带有 id 和值的元组。我知道我正在寻找的 id,我想从我传入的三个元组中选择正确的元组。我打算用两个 match 语句来做到这
我是一名优秀的程序员,十分优秀!