Yatendra Khandelwal

  • Random
  • Archive
  • RSS
  • Ask me anything

jQuery ListCollapse

(Migrated from old wordpress blog post dated 1/9/2011)

This plugin is meant to collapse/expand a list of items that grows beyond certain predefined number of items. It filters and collapses a list when data is bound, added or removed. If number of items are more than specified number n it displays first n items and displays an expand(customizable) link. When a user clicks on this link it displays the entire list and changes this link to collapse(customizable).

Download listcollapse

(Note: This plugin is based on Collapsorz 1.1 created by Aaron Kuzemchak. I have customized it to be able to be called whenever an item is added or removed and some minor modifications is think were required for dynamic list where items are added and removed on the fly)

Usage

$(listelement).listcollapse();

$(listelement).listcollapse(options);

Options

(All parameters are optional)

toggle

To select elements that you wish to collapse. By default it will collapse all direct children of the list selected.

maximum

Maximum number of elements to show. Collapses all items beyond this number. It defaults to 5.

showText

Text to be shown for the expand link. It defaults to Show.

hideText

Text to be shown for the collapse link. It defaults to Hide.

linkLocation

Whether to display expand/collapse link before or after the selected list. You can choose one of the following settings:

  • after—Places the link after the list. This is the default setting.
  • before—Places the link before the list.

defaultState

Whether the list should be displayed expanded or collapsed by default.

  • collapsed—List will be collapsed by default. This is the default setting.
  • expanded—List will be expanded by default.

wrapLink

HTML to wrap around the link.

    • #jquery
  • 8 months ago
  • Comments
  • Permalink
  • Share
    Tweet

About

.... technology, business, technology in business, business in technology and more ....
  • Projects

Me, Elsewhere

  • @yatendra on Twitter
  • Linkedin Profile
  • yatendra on github
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr