Skip to content

Instantly share code, notes, and snippets.

@ercanertan
Last active July 24, 2018 18:04
Show Gist options
  • Save ercanertan/87adee83e340663ad85133655ec0e33c to your computer and use it in GitHub Desktop.
Save ercanertan/87adee83e340663ad85133655ec0e33c to your computer and use it in GitHub Desktop.
Bootstrap Accordion Draggable Sortable. http://jsfiddle.net/mt8wfrq2/
http://jsfiddle.net/mt8wfrq2/
Blade
<div id="accordion" role="tablist">
<div class="card">
<div class="card-header" role="tab" id="headingOne">
<h5 class="mb-0">
<a data-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<i class="fa fa-arrows" aria-hidden="true"></i> Collapsible Group Item #1
</a>
</h5>
</div>
<div id="collapseOne" class="collapse" role="tabpanel" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" role="tab" id="headingTwo">
<h5 class="mb-0">
<a class="collapsed" data-toggle="collapse" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
<i class="fa fa-arrows" aria-hidden="true"></i> Collapsible Group Item #2
</a>
</h5>
</div>
<div id="collapseTwo" class="collapse" role="tabpanel" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" role="tab" id="headingThree">
<h5 class="mb-0">
<a class="collapsed" data-toggle="collapse" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
<i class="fa fa-arrows" aria-hidden="true"></i> Collapsible Group Item #3
</a>
</h5>
</div>
<div id="collapseThree" class="collapse" role="tabpanel" aria-labelledby="headingThree" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
Script
<script>
$( function() {
$('#accordion').sortable();
$('#accordion').on("show.bs.collapse", function(){ $('#accordion').sortable('disable'); });
$('#accordion').on("hide.bs.collapse", function(){ $('#accordion').sortable('enable'); });
$('#accordion').accordion({
collapsible: true,
active: true,
heightStyle: 'fill',
header: 'card'
}).sortable({
change: function(event, ui) {
ui.placeholder.css({visibility: 'visible', border : '5px solid yellow'});
},
items: '.card'
}).bind('sortupdate', function(e, ui) {
console.log('make ajax');
});
} );
</script>
Webpack
window.sortable = require("jquery-ui"),require('jquery-ui/ui/widgets/sortable'),require('jquery-ui/ui/disable-selection'),require('jquery-ui/ui/widgets/accordion');
Sass
@import "~jquery-ui/themes/base/all.css";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment