Tab with xEditor

I have a tabbar with 5+ tabs, some of which will have an xEditor. Tabs can be opened/closed at any time. I need a way to “attach” the xEditor object pointer

WriteMessageEditor=new dhtmlXEditor(“editorObj”+TabId);

to the tab when it is first created so when close a tab the contents of the xEditor can be copied. The tabs are dynamic so I can’t use a global variable. There could be 50 tabs open (for example).

Something like xGrids setUserData() would be nice.

Any idea of how to do this?

Hello,

the problem is not clear enough. Tabbar doesn’t provide userdata or similar functionality.

To get editor content you may use getContent() method. Also the editor can be attached by attachEditor method (dhtmlxcontainer.js should be included):

var editor = tabbar.cells(tabId).attachEditor();

Hard to explain in a message. Imagine a tab-based email program:

Open a new tab to write a new message. It has an xEditor. Start writing…

I open another write tab so 2 are now open. It also has an xEditor.

I open another, and another…not likely but could happen.

…I am done writing the second message. I hit send. I need the pointer to the xEditor to getContent() from it. I am done writing the first message, hit send. I need the pointer to that xEditor to getContent() from it. And on down the line.

How can I store all the object pointers? If I could somehow “attach” it to the tab I could get it from the user data (or whatever) when switch tabs. I use

MailTabbar.addTab(TabId,Dat…)

With some stuff in the TabId, but can’t put an object in there. When switch tabs I look at the TabId for details.

xEditor doesn’t have an Id tag to store it somewhere.

I don’t want to use a global array like

xEditor[2]=new dhtmlXEditor(“editorObj”+TabId);
xEditor[13]=new dhtmlXEditor(“editorObj”+TabId);

if I can get around it some other way. If I have to I will, but not my first choice.

Just looking for any ideas.

What would be really nice is:

Make your tabbar. attachMenu, attachEditor, etc., to tabs…

Then be able to do:

text=MyTabbar.cells(1).editor.getContent();
MyTabbar.cells(3).grid.addRow(id,…);

You already have the object pointer internally when attachGrid() (and others) are called.

You may try to access editor object as follows:

var cell = MyTabbar.cells(1);
var text = cell.vs[cell.av].editor.getContent();

The same is for the grid:

var grid = cell.vs[cell.av].grid;

Nice. That worked. I still need to do some modifying but I can move on.

Thank you!