Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a dynamic nested sortable accordion #135

Open
mostafa272 opened this issue Jul 30, 2020 · 0 comments
Open

Create a dynamic nested sortable accordion #135

mostafa272 opened this issue Jul 30, 2020 · 0 comments

Comments

@mostafa272
Copy link

mostafa272 commented Jul 30, 2020

Hi
I want to create a nested sortable accordion, but I can not place accordion panels as child of other panel or sort them.

` jQuery('.accordion_box').accordion({
collapsible: true,
active: false,
heightStyle:"content",
header: 'h3'
}).nestedSortable({
items: 'li',
handle: 'h3',
toleranceElement: '> div',
});

jQuery('.accordion_box').on('accordionactivate', function (event, ui) {
    if (ui.newPanel.length) {
        jQuery('.accordion_box').sortable('disable');
    } else {
        jQuery('.accordion_box').sortable('enable');
    }
});

jQuery('.cni_items_new').on('click',function(){
var item_count = jQuery('.accordion_box .s_panel').length;
var num = Number(item_count+1);
//output is a string of html tags li is container, h3 is handle of accordion
jQuery('.accordion_box').append(output);
jQuery('.accordion_box').accordion( "refresh" );

});`

When user click on a button with .cni_items_new class, a new panel added to accordion.
The output variable that appends to accordion is a li container includes h3 tag as handle of panel and a div for panel content.

HTML code:
<ol class="items_container accordion_box"></ol>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant