addremove.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Add and Remove Layout - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Add and Remove Layout</h2>
  14. <div class="demo-info">
  15. <div class="demo-tip icon-tip"></div>
  16. <div>Click the buttons below to add or remove region panel of layout.</div>
  17. </div>
  18. <div style="margin:10px 0;">
  19. <span>Select Region Panel:</span>
  20. <select id="region">
  21. <option value="north">North</option>
  22. <option value="south">South</option>
  23. <option value="east">East</option>
  24. <option value="west">West</option>
  25. </select>
  26. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="addPanel()">Add</a>
  27. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="removePanel()">Remove</a>
  28. </div>
  29. <div id="cc" class="easyui-layout" style="width:700px;height:350px;">
  30. <div data-options="region:'north'" style="height:50px"></div>
  31. <div data-options="region:'south',split:true" style="height:50px;"></div>
  32. <div data-options="region:'east',split:true" title="East" style="width:100px;"></div>
  33. <div data-options="region:'west',split:true" title="West" style="width:100px;"></div>
  34. <div data-options="region:'center',title:'Center'"></div>
  35. </div>
  36. <script type="text/javascript">
  37. function addPanel(){
  38. var region = $('#region').val();
  39. var options = {
  40. region: region
  41. };
  42. if (region=='north' || region=='south'){
  43. options.height = 50;
  44. } else {
  45. options.width = 100;
  46. options.split = true;
  47. options.title = $('#region option:selected').text();
  48. }
  49. $('#cc').layout('add', options);
  50. }
  51. function removePanel(){
  52. $('#cc').layout('remove', $('#region').val());
  53. }
  54. </script>
  55. </body>
  56. </html>