jQuery UI Layout: How to get the 3 toggler buttons for close, resize, full mode of showing panel

1.3k Views Asked by At

My requirement refers to the demo referred in jQuery UI Layout

I need to get the 3 togglers as demonstrated above but my integration is not showing me the three coloured toggler buttons. I checked the loading of the content on the pages on demo and my site but the div itseld is not populating in my html... :(

Am I missing something?

I did the things as below:

$(document).ready(function(){

    // CREATE THE LAYOUT
    myLayout = $('body').layout({
        resizeWhileDragging:            true
    ,   fxName:                         "none"
    ,   west__size:                     westDefaultSize
    ,   south__size:                    southDefaultSize
    ,   spacing_open:                   8
    ,   spacing_closed:                 8
    ,   north__spacing_open:            0
    ,   west__togglerLength_closed:     105
    ,   west__togglerLength_open:       105
    ,   south__togglerLength_closed:    105
    ,   south__togglerLength_open:      105
    ,   west__togglerContent_closed:    toggleButtons
    ,   west__togglerContent_open:      toggleButtons
    ,   south__togglerContent_closed:   toggleButtons
    ,   south__togglerContent_open:     toggleButtons
    });

    // SET OBJECT POINTERS FOR CONVENIENCE
    var
        $westToggler  = myLayout.togglers.west
    ,   $southToggler = myLayout.togglers.south
    ;

     var toggleButtons = '<div class="btnToggler"></div>'
            + '<div class="btnReset"></div>'
            + '<div class="btnExpand"></div>';
    // UN-BIND DEFAULT TOGGLER FUNCTIONALITY
    $westToggler.unbind("click");
    $southToggler.unbind("click");

    // BIND CUSTOM WEST METHODS
    $westToggler.find(".btnToggler")    .click( toggleWest );
    $westToggler.find(".btnExpand")     .click( expandWest );
    $westToggler.find(".btnReset")      .click( resetWest );

    // BIND CUSTOM SOUTH METHODS
    $southToggler.find(".btnToggler")   .click( toggleSouth );
    $southToggler.find(".btnExpand")    .click( expandSouth );
    $southToggler.find(".btnReset")     .click( resetSouth );

    // ADD TOOLTIPS TO CUSTOM BUTTONS
    $(".btnExpand").attr("title", "Expand to full size");
    $(".btnReset") .attr("title", "Reset size to default");

});

// CUSTOM WEST METHODS
function toggleWest  (evt) { myLayout.toggle("west"); evt.stopPropagation(); };
function expandWest  (evt) { sizePane("west", 500); };
function resetWest   (evt) { sizePane("west", westDefaultSize); };

// CUSTOM SOUTH METHODS
function toggleSouth (evt) { myLayout.toggle("south"); evt.stopPropagation(); };
function expandSouth (evt) { sizePane("south", 9999); }; // ie, make as big as possible
function resetSouth  (evt) { sizePane("south", southDefaultSize); };

// GENERIC HELPER FUNCTION
function sizePane (pane, size) {
    myLayout.sizePane(pane, size);
    myLayout.open(pane); // open pane if not already
};

There was only one difference:

var myLayout = $('#layout-wrapper').layout();

I am calling layout at page load then on button click I'm adding the togglers:

myLayout.addToggleBtn();

something like above.

Please let me know how we can achieve the layout with togglers when instantiation is done for layout.

1

There are 1 best solutions below

3
On

First that I can see is that you are missing toggleButtons definition. In the example that you posted it is

toggleButtons = '<div class="btnToggler"></div>'
          + '<div class="btnReset"></div>'
          + '<div class="btnExpand"></div>';

But I do not see them in your code, yet you are refering to them in your layout definition?