1

I'm using jQuery UI Layout Plug-in (http://layout.jquery-dev.net/). I need to load a layout on a modal window depending on certain parameters. So on-event I do something like:

$('<div id="container"><div class="ui-layout-west"> <div class="left-panel"><div class="fuelux">Somthing here</div> </div> </div> <div class="ui-layout-center">Something else here </div></div>').layout();

I have no idea why it does not build the layout. Does the plug-in support something like that?..

Help is appreciated.

4
  • Sure, that should work. However, are you actually adding the content to the page? I'd expect them to need to be part of the dom before you call layout. Commented Jul 15, 2013 at 17:51
  • Yes, I'm adding the content to the modal. So I guess I have to create the dialog first, then lookup for #content and call layout() ? Commented Jul 15, 2013 at 17:55
  • Basically, yes. See @cfs's answer and the comment. Commented Jul 15, 2013 at 18:00
  • Thanks @cfs. This helped me with the issue: jsfiddle.net/YGT5p/4 Commented Jul 15, 2013 at 19:07

1 Answer 1

1

You'll need to add your HTML to the DOM first, then initialize the layout. In the example below, I'm adding the container to the body, but you could add it to any element in the DOM:

$('<div id="container"><div class="ui-layout-west"> <div class="left-panel"><div class="fuelux">Somthing here</div> </div> </div> <div class="ui-layout-center">Something else here </div></div>').appendTo('body').layout();

Working Demo

Sign up to request clarification or add additional context in comments.

9 Comments

Note, you could also just do $('<div id="container"><div class="ui-layout-west"> <div class="left-panel"><div class="fuelux">Somthing here</div> </div> </div> <div class="ui-layout-center">Something else here </div></div>').appendTo('body').layout()
Nice... I wasn't sure what appendTo would be returning; but you're right, I'll update to save the unnecessary lookup
It seems to work.. partially.. bacause now all my layout disappears. $('<div title="Column expression"><div></div></div>').append($expressionEditor).appendTo('body').dialog({ modal: true, buttons: { .... }, open: function (event, ui) { $(this).find('#container').layout(); } });
do you have other layouts on the page that are created before this one?
Yes, I do have other layouts. The problem is that I want to show this new layout in a modal dialog.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.