我需要下面的html代码的手风琴列表。我只是希望它能够在点击“技术”时打开(展开)。再次单击时,它将关闭(折叠)。
这是我的HTML代码
$result = Yii::app()->db->createCommand()->setFetchMode(PDO::FETCH_OBJ)
->select('t.id, "contract" AS type')
->from('test t')
->where('t.company_id=1')
->queryAll();
我没有简单的html javascript代码。它是用ionic / cordova编写的。如何在点击时将其设置为可折叠和可扩展的简单预设?
答案 0 :(得分:1)
有多种方法可以解决这个问题,我根据您的要求找到了这种方法
您的HTML代码
<!-- Techincal -->
<ul>
<li class="item-stable item-icon-right"
ng-click="toggleGroup(0)"
ng-class="{active: isGroupShown(0)}">
<button class="item-text-center item-text-wrap">Techincal </button>
</li>
<div class="item-accordion"
ng-show="isGroupShown(0)">
<div class="item">
<div class="row">
<!--List-->
<div class="item">
<div class="row centerized">
<div class="col col-40"></div>
<div class="col col-30">Min</div><div class="col col-30">Max</div>
</div>
<div class="row">
<div class="col col-40">Tech spec</div>
<div class="col col-30"><input type="number" placeholder="0" ng-model="searchQuery.techMin"></div>
<div class="col col-30"><input type="number" placeholder="5" ng-model="searchQuery.techMax"></div>
</div>
<div class="row">
<div class="col col-40">Radius</div>
<div class="col col-30"><input type="number" placeholder="-1000" ng-model="searchQuery.radiusMin"></div>
<div class="col col-30"><input type="number" placeholder="1000" ng-model="searchQuery.radiusMax"></div>
</div>
</div>
</div>
</div>
</div>
</ul>
这是你的js代码
<script>
$scope.toggleGroup = function(group) {
if ($scope.isGroupShown(group)) {
$scope.shownGroup = null;
} else {
$scope.shownGroup = group;
}
};
$scope.isGroupShown = function(group) {
return $scope.shownGroup === group;
};
</script>
答案 1 :(得分:0)
这样的东西,没有额外的模块。只是一个简单的解决方案来切换一些内容。如果需要,可以使用CSS完成动画。这只是为了让您开始初步问题。
查看强>
<!-- Techincal -->
<div class="item">
<div class="row">
<div style="padding:10px; background: gray;" class="col boldText" ng-click="vm.toggleContainer()">Technical</div>
</div>
<!--List-->
<div class="item" style="margin-top:25px;" ng-if='vm.showTechnicalDetails'>
<div class="row centerized">
<div class="col col-40"></div>
<div class="col col-30">Min</div>
<div class="col col-30">Max</div>
</div>
<div class="row">
<div class="col col-40">Tech spec</div>
<div class="col col-30">
<input type="number" placeholder="0" ng-model="searchQuery.techMin">
</div>
<div class="col col-30">
<input type="number" placeholder="5" ng-model="searchQuery.techMax">
</div>
</div>
<div class="row">
<div class="col col-40">Radius</div>
<div class="col col-30">
<input type="number" placeholder="-1000" ng-model="searchQuery.radiusMin">
</div>
<div class="col col-30">
<input type="number" placeholder="1000" ng-model="searchQuery.radiusMax">
</div>
</div>
</div>
</div>
</div>
JS Angular part(vm
方法)
angular
.module('app', [])
.controller('MainController', MainController)
function MainController() {
var vm = this;
vm.toggleContainer = toggleContainer;
vm.showTechnicalDetails = false;
function toggleContainer() {
vm.showTechnicalDetails = !vm.showTechnicalDetails;
}
}
JSFiddle:https://jsfiddle.net/DaanDeSmedt/Ln2dgmer/
JS Angular part($scope
方法)
angular
.module('app', [])
.controller('MainController', MainController)
function MainController($scope) {
$scope.showTechnicalDetails = false;
$scope.toggleContainer = function(){
$scope.showTechnicalDetails = !$scope.showTechnicalDetails;
}
}