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

Allows starting individual branches expanded or collapsed #116

Open
wants to merge 1 commit into
base: 2.0alpha
Choose a base branch
from

Conversation

dustinbolton
Copy link

This update allows you to explicitly define the starting state of individual branches to be either expanded or collapsed beyond the default starting state of all collapsed or all expended. This allows overriding the default startCollapsed option on a per-branch level as needed.

On any branches you wish to start as explicitly collapsed or expanded, simply apply your defined (or default if you did not define) expandedClass or collapsedClass classname to the applicable

  • branch (or whatever you are using as your defined entity in the "items" setting).

    I needed this so that I could ‘remember’ the state of individual branches and restore them on page load.

  • This update allows you to preset the expanded or collapsed class on
    individual branches to give finer grain control over individual branch
    status on start. This allows overriding the default startCollapsed
    option on a per-branch level as needed.
    
    I needed this so that I could ‘remember’ the state of individual
    branches and restore them on page load.
    @deanrad
    Copy link

    deanrad commented Feb 10, 2014

    Could you include a usage example ? In the absence of tests, that's the closest thing..

    @dustinbolton
    Copy link
    Author

    Here's a usage example. If you wish to override the default behavior (which is either all open or all closed based on the startCollapsed setting), just apply the appropriate class to the li to force it to start whichever way you like.

    <ol class="sortable">
        <li class="mjs-nestedSortable-expanded"><div>Starts open, overriding default</div></li>
        <li class="mjs-nestedSortable-collapsed"><div>Starts collapsed, overriding default</div></li>
        <li><div>Starts open or closed based on startCollapsed setting; default behavior </div></li>
    </ol>

    @@ -63,8 +63,10 @@
    if ($li.children(self.options.listType).length) {
    $li.addClass(self.options.branchClass);
    // expand/collapse class only if they have children
    if (self.options.startCollapsed) $li.addClass(self.options.collapsedClass);
    Copy link
    Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Usage example:

    <ol class="sortable">
        <li class="mjs-nestedSortable-expanded"><div>Starts open, overriding default</div></li>
        <li class="mjs-nestedSortable-collapsed"><div>Starts collapsed, overriding default</div></li>
        <li><div>Starts open or closed based on startCollapsed setting; default behavior </div></li>
    </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

    Successfully merging this pull request may close these issues.

    2 participants