Question

I can't seem to get the collapsible part working with nestedSortable.

http://jsfiddle.net/meisam/vq9dD/

Here is the javascript I'm using:

$('ol.sortable').nestedSortable({
    disableNesting: 'no-nest',
    forcePlaceholderSize: true,
    handle: 'div',
    helper: 'clone',
    items: 'li',
    opacity: .6,
    placeholder: 'placeholder',
    revert: 250,
    tabSize: 25,
    tolerance: 'pointer',
    toleranceElement: '> div',
    isTree: true,
    startCollapsed: true,
    update: function () {
        order = $('ol.sortable').nestedSortable('serialize');
        console.log(order); 
    }
});

$('.disclose').on('click', function() {
    $(this).closest('li').toggleClass('mjs-nestedSortable-collapsed').toggleClass('mjs-nestedSortable-expanded');
})
Était-ce utile?

La solution

The version of the plugin you were using was not working. I upgraded the plugin and changed the collapsible code to the following:

$('.mjs-nestedSortable-collapsed').on('click', function () {
    $(this).toggleClass('mjs-nestedSortable-collapsed').toggleClass('mjs-nestedSortable-expanded');
});

Fiddle here

Autres conseils

The expand/collapse buttons for new nestings (if I click and drag one row under another) do not work. Only the ones showing on load work.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top