EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: tslatt on August 02, 2011, 01:19:22 PM



Title: How to give dynamically created panels a unique id within the portal layout?
Post by: tslatt on August 02, 2011, 01:19:22 PM
I am dynamically adding panels to the portal layout using the example provided in the demo:

Code:
//dynamically add widgets
function add(){
  //for 0-2 (add 3 widgets)
  for(var i=0; i<3; i++){
   
    //the new widget will be appended inside the <body>
    var p = $('<div><\/div>').appendTo('body');
   
    //create a panel (a widget)
    p.panel({
      title: 'Title ' + i,  //the widget's title (header)
      content: 'x',         //the widget's content (the box)
      closable: true,       //adds an 'X' control so the widget can be closed
      collapsible: true     //adds an "^" control so the widget can be collapsed/expanded
    });
   
    //add the new panel to the bottom of a portal column
    $('#cPortal').portal('add', { //it goes within the portal area #cPortal
      panel: p,                   //add the widget p specified above
      columnIndex: i              //add it after the last panel within column i (columns are numbered 0-1-2)
    });
  }   
}

How can I give each individual panel its own unique id?

I want each panel to have an id as a step towards saving the state of the portal (which panels are shown, in which columns, in which order). But if there is another way to get this info, please let me know...