javascript - Twitter Bootstrap Multi level accordion with jQueryUI sorting -
if drop first level group "group #2" element in sub level group list, collapse (close) parent accordion. how solve problem?
$(document).ready(function() { //append headings indicatoe icon-plus $('.accordion-heading').prepend('<i class="ui-icon ui-icon-triangle-1-e"></i>'); // change indicator element sub-menu $('.accordion-body').on('show', function(e) { e.stoppropagation(); $(this).siblings('.accordion-heading').children('.ui-icon').removeclass('ui-icon-triangle-1-e').addclass('ui-icon-triangle-1-s'); }); //reverse $('.accordion-body').on('hide', function(e) { e.stoppropagation(); $(this).siblings('.accordion-heading').children('.ui-icon').removeclass('ui-icon-triangle-1-s').addclass('ui-icon-triangle-1-e'); }); //make tabs sortable $(".accordion-body > .accordion, .sidebar").sortable({ connectwith: ".accordion", placeholder: "ui-state-highlight" }); });
html
<nav class="accordion1 accordion sidebar"> <div class="accordion-group"> <div class="accordion-heading"> <a data-toggle="collapse" data-parent=".accordion2" href=".collapse-one"> group #1 </a> </div> <div class="collapse-one accordion-body collapse" style="height: 0px;"> ... <div class="accordion2 accordion"> <div class="accordion-group"> <div class="accordion-heading"> <a data-toggle="collapse" data-parent=".accordion2" href=".collapse-one-one"> sub-group #1 </a> </div> <div class="collapse-one-one accordion-body collapse" style="height: 0px;"> ... </div> </div> <div class="accordion-group"> <div class="accordion-heading"> <a data-toggle="collapse" data-parent=".accordion2" href=".collapse-one-two"> sub-group #2 </a> </div> <div class="collapse-one-two accordion-body collapse" style="height: 0px;"> ... </div> </div> <div class="accordion-group"> <div class="accordion-heading"> <a data-toggle="collapse" data-parent=".accordion2" href=".collapse-one-three"> sub-group #3 </a> </div> <div class="collapse-one-three accordion-body collapse"> ... </div> </div> </div> </div> </div> <div class="accordion-group"> <div class="accordion-heading"> <a data-toggle="collapse" data-parent=".accordion1" href=".collapse-two"> group #2 </a> </div> <div class="collapse-two accordion-body collapse" style="height: 0px;"> ... </div> </div>
the collapsing , expanding events bound @ loading, , affect same elements after rearranging.
don't know if twitter-bootstrap can let override these events , reset elements, need collapse , expand. if not - maybe consider extending version.
Comments
Post a Comment