Click here to Skip to main content
15,888,069 members
Articles / jQuery

jQuery Splitter

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
6 Jan 2012CPOL1 min read 59.9K   8   2
jQuery splitter

The jQuery Splitter plug in consists of a movable split bar that divides a container’s display area into two or more resizable panels. We are going to show you some of the basic features of the Splitter and how to add it to your web page.

vertical splitter

HTML Coding

HTML markup for a splitter looks like this:

HTML
<div id="MySplitter">
  <div> First content goes here </div>
  <div> Second content goes here </div>
</div>

The top-level div has two child divs for the splitter panels. (In a horizontal splitter, the first panel is the top and the second is the bottom.) The splitter dynamically adds a splitbar that goes between the panels. To create the splitter, you need to select the MySplitter div in a jQuery object and pass it to the jqxSplitter constructor.

Javascript Coding

JavaScript
<script type="text/javascript">
    $(document).ready(function () {
        $('#MySplitter').jqxSplitter
        ({ width: 400, height: 400, panels: [{ size: 200 }, { size: 200}] });
    });
</script>

The initialization includes setting the splitter’s width, height and panels size. The size of the first panel defines the initial splitbar position. Users can move the splitbar by moving the mouse over it and then clicking and dragging it.

To change the splitter orientation, you can set the ‘orientation’ property to either ‘horizontal’ or ‘vertical’.

JavaScript
<script type="text/javascript">
    $(document).ready(function () {
        $('#MySplitter').jqxSplitter
        ({orientation: 'vertical', width: 400, 
        height: 400, panels: [{ size: 200 }, { size: 200}] });
    });
</script>

Image 2

The plug in has an option that lets the code or user “dock” the splitbar to one side of the splitter, collapsing one panel and using the entire splitter area for the other panel. To use this option, specify the collapsible option in the panels definition when creating the splitter. If you specify collapsible: false, the splitter will allow the splitbar to be collapsed only by code with the ‘collapseAt’ function.

JavaScript
<script type="text/javascript">
    $(document).ready(function () {
        $('#MySplitter').jqxSplitter({orientation: 'vertical', width: 400, height: 400, 
        panels: [{ size: 200, collapsible: false }, { size: 200, collapsible: false}] });
    });
</script>

Adding an additional panel to the splitter is easy. The HTML markup below defines the structure for a splitter with three panels.

HTML Coding

HTML
<div id="MySplitter">
    <div>
        First content goes here
    </div>
    <div>
        Second content goes here
    </div>
    <div>
        Third content goes here
    </div>
</div>

JavaScript Coding

JavaScript
<script type="text/javascript">
    $(document).ready(function () {
        $('#MySplitter').jqxSplitter({ width: 400, height: 400, 
        panels: [{ size: 150 }, { size: 150 }, { size: 100}] });
    });
</script>

jquery ui splitter

This article was originally posted at http://www.jqwidgets.com/jquery-ui-splitter

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
jQWidgets
United States United States
jQWidgets specializes in the development of platform independent and cross-browser compatible presentation layer components for building modern web-based applications for PC, Touch and Mobile. Our product provides developers with the essential set of User Interface widgets needed to streamline their development and reduce project costs.
Our goal is to help our customers deliver better web-based applications that can be accessed through any device and are pleasure to use.
This is a Organisation

13 members

Comments and Discussions

 
QuestionIs this Paid or free? Pin
chirag.khatsuriya17-Apr-12 18:46
chirag.khatsuriya17-Apr-12 18:46 
AnswerRe: Is this Paid or free? Pin
jqwidgets18-Apr-12 3:50
jqwidgets18-Apr-12 3:50 
It's Free for non-commercial use.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.