如何在Jquery可嵌套中创建自动折叠所有列表项? [英] How to create auto collapsed all list item in Jquery nestable?

查看:52
本文介绍了如何在Jquery可嵌套中创建自动折叠所有列表项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用菜单编辑器的 Jquery 插件 Nestable 。我想让所有菜单项自动折叠,但也要在用户点击每个可展开图标时展开。

I'm using Jquery plugin Nestable for menus editor. I want all menu items to auto collapse, but also to expand when a user clicks on each expandable icon.

这是 Jquery Nestable 插件。

 $(document).ready(function(){
   $("#product_list").nestable({
      maxDepth: 10,
      collapsedClass:'dd-collapsed',
   });
 });


推荐答案

由于此处没有多少选项插件您可以执行的操作是在创建可嵌套后手动折叠,如下所示:

Since there isn't much option available in this plugin what you can do is manually collapse once the nestable has been created as below:

$(document).ready(function(){
   $("#product_list").nestable({
      maxDepth: 10,
      collapsedClass:'dd-collapsed',
   }).nestable('collapseAll');//Add this line
   //$("#product_list").nestable('collapseAll') //Or this
});

DEMO 展开视图而不会在展开时崩溃

DEMO with expanded view without collapsing on load and

DEMO 加载了折叠视图

DEMO with collapsed view on load

这篇关于如何在Jquery可嵌套中创建自动折叠所有列表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆