我有一个视图dashboard.blade.php
。
它有多种形式。我已经在<a>
元素中设置了数据属性data-toggle='collapse
。
使用键盘向下箭头方法时,这对单个窗体正常工作。
再次单击该arrow
时,第一个窗体将从视图中隐藏。
但是,当我单击第二个<a>
时,虽然第一个表单已经打开,但两个表单同时显示。
我需要管理它以一次显示一个表单,并通过单击下一个表单隐藏另一个表单。
下面是我的代码(dashboard.blade.php
(。
第一种形式:
<div class="panel">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a data-toggle="collapse"
data-parent="#accordion3"
href="#collapseTwo3"
aria-expanded="false"
aria-controls="collapseTwo3"
data-expandable="false"><i class="material-icons pmd-sm pmd-accordion-icon-left">toys</i>Brands
<i class="material-icons md-dark pmd-sm pmd-accordion-arrow">keyboard_arrow_down</i></a>
</h4>
</div>
<div id="collapseTwo3" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<form class="form-horizontal"
method="post"
enctype="multipart/form-data"
action="{{ url('importBrands') }}">
{{ csrf_field() }}
<div class="form-group files">
<label>Upload Your File</label>
<input type="file" name="import_file" />
</div>
<div align="right">
<!-- <button class="btn btn-primary">Export</button> -->
<button class="btn btn-primary">Import</button>
</div>
</form>
</div>
</div>
</div>
第二种形式:
<div class="panel">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a data-toggle="collapse"
data-parent="#accordion3"
href="#collapseThree3"
aria-expanded="false"
aria-controls="collapseThree3"
data-expandable="false"><i class="material-icons pmd-sm pmd-accordion-icon-left">category</i>Categories
<i class="material-icons md-dark pmd-sm pmd-accordion-arrow">keyboard_arrow_down</i></a>
</h4>
</div>
<div id="collapseThree3" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
<form class="form-horizontal"
method="post"
enctype="multipart/form-data"
action="{{ url('importCategories') }}">
{{ csrf_field() }}
<div class="form-group files">
<label>Upload Your File</label>
<input type="file" name="import_file" />
</div>
<div align="right">
<!-- <button class="btn btn-primary">Export</button> -->
<button class="btn btn-primary">Import</button>
</div>
</form>
</div>
</div>
</div>
材料.js
var FloatingLabel = function ($$$1) {
// constants >>>
var DATA_KEY = 'md.floatinglabel';
var EVENT_KEY = "." + DATA_KEY;
var NAME = 'floatinglabel';
var NO_CONFLICT = $$$1.fn[NAME];
var ClassName = {
IS_FOCUSED: 'is-focused',
HAS_VALUE: 'has-value'
};
var Event = {
CHANGE: "change" + EVENT_KEY,
FOCUSIN: "focusin" + EVENT_KEY,
FOCUSOUT: "focusout" + EVENT_KEY
};
var Selector = {
DATA_PARENT: '.floating-label',
DATA_TOGGLE: '.floating-label .custom-select, .floating-label .form-control' // <<< constants
};
var FloatingLabel =
/*#__PURE__*/
function () {
function FloatingLabel(element) {
this._element = element;
this._parent = $$$1(element).closest(Selector.DATA_PARENT)[0];
}
var _proto = FloatingLabel.prototype;
_proto.change = function change() {
if ($$$1(this._element).val() || $$$1(this._element).is('select') && $$$1('option:first-child', $$$1(this._element)).html().replace(' ', '') !== '') {
$$$1(this._parent).addClass(ClassName.HAS_VALUE);
} else {
$$$1(this._parent).removeClass(ClassName.HAS_VALUE);
}
};
_proto.focusin = function focusin() {
$$$1(this._parent).addClass(ClassName.IS_FOCUSED);
};
_proto.focusout = function focusout() {
$$$1(this._parent).removeClass(ClassName.IS_FOCUSED);
};
FloatingLabel._jQueryInterface = function _jQueryInterface(event) {
return this.each(function () {
var _event = event ? event : 'change';
var data = $$$1(this).data(DATA_KEY);
if (!data) {
data = new FloatingLabel(this);
$$$1(this).data(DATA_KEY, data);
}
if (typeof _event === 'string') {
if (typeof data[_event] === 'undefined') {
throw new Error("No method named "" + _event + """);
}
data[_event]();
}
});
};
return FloatingLabel;
}();
$$$1(document).on(Event.CHANGE + " " + Event.FOCUSIN + " " + Event.FOCUSOUT, Selector.DATA_TOGGLE, function (event) {
FloatingLabel._jQueryInterface.call($$$1(this), event.type);
});
$$$1.fn[NAME] = FloatingLabel._jQueryInterface;
$$$1.fn[NAME].Constructor = FloatingLabel;
$$$1.fn[NAME].noConflict = function () {
$$$1.fn[NAME] = NO_CONFLICT;
return FloatingLabel._jQueryInterface;
};
return FloatingLabel;
}($);
我想,你忘记了在代码中添加几行。在代码中添加一些行(
<div class="panel-group" id="accordion3">
paste your code here
</div>
使用Bootstraps框架的简单解决方案。完整示例(
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Collapsible Group 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body"> First Form Html </div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Collapsible Group 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body"> Second Form Html </div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse3">Collapsible Group 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body"> Third Form Html </div>
</div>
</div>