EasyUI Forum
September 14, 2025, 10:09:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to create a dynamic layout  (Read 8745 times)
TampaBay55
Newbie
*
Posts: 7


View Profile Email
« on: February 27, 2015, 12:21:10 PM »

Using jQuery and EasyUI, I would like to know how to dynamically create a layout.  The following is my attempt; however is doesn't appear to work:

Code:
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>CTest Site</title>
    <link rel="stylesheet" type="text/css" href="app/lib/jquery-easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="app/lib/jquery-easyui/themes/icon.css">
    <script data-main="app/app" src="app/lib/require-js/require.js"></script>
    </head>
    <body></body>
    </html>
My app.js

Code:
    requirejs.config({
        "baseUrl": "app/lib",
        "paths": {
          "app": "/app",
          "jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min",
          "easyui": "jquery-easyui/jquery.easyui.min"
        }
    });
    define(["jquery"], function($){
    require(["easyui"],function(){
    require(["app/views/viewport"],function(){
    });
    });
    });
My viewport.js

Code:
    //Layout the page
    $('body').addClass("easyui-layout");
    $('body').append("<div id='spa-head' data-options=\"region:'north'\"></div>");
    $('body').append("<div id='spa-west' data-options=\"region:'west',width:300,split:true\"></div>");
    $('body').append("<div id='spa-cntr' data-options=\"region:'center',title:'CENTER'\"></div>");
The page should have rendered a layout with regions for north, west and center. The center panel would have been titled and the west panel would have had a resizable splitter. Instead, the page was blank even though I could see the proper elements rendered in the console.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 28, 2015, 12:29:04 AM »

Please try the code below instead.
Code:
$('body').layout();
$('body').layout('add', {
  region:'center',
  title:'CENTER',
  id:'spa-cntr'
}).layout('add', {
  region:'north',
  height:60,
  id:'spa-head'
}).layout('add', {
  region:'west',
  width:300,
  split:true,
  id:'spa-west'
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!