PDA

View Full Version : create 300 tooltip



toto63
4 Mar 2010, 12:36 AM
Hello,

i need to create 300 AJAX tootip.
i create code for each tootip (see below). It's a too big js file.
I don't know how use each name of target who begin by T to create a tootip with a params include in the name on the target (1, 2, 3, ...). i have 300 div with id like T1 to T300.

thanks

Ext.onReady(function(){
new Ext.ToolTip({
target: 'T1',
autoHeight: true,
autoWidth: true,
autoLoad: {
url: 'T_infobulle.php',
params: 'id=1'
}
});
new Ext.ToolTip({
target: 'T2',
autoHeight: true,
autoWidth: true,
autoLoad: {
url: 'T_infobulle.php',
params: '2'
}
});
Ext.QuickTips.init();
})

evant
4 Mar 2010, 12:39 AM
Use a loop...

Animal
4 Mar 2010, 12:49 AM
I don't think that's a good idea in the first place.

There will be a better way to achieve the UI functionality that you are looking for.

Can you describe what you want to achieve?

toto63
4 Mar 2010, 3:05 AM
Yes. i have a classical table with a lot rows and lines.
In fact, i have a value for one year but i vant to see another the historic (10 years) of the value with another grid.. Then i have a tootip on each number for the current year who call an ajax table for the history.
then i create 300 tooltips on on js. But the js is big. I think it's better to say in few line of js and to create a tootip on each div begin by T and call the new grid with params the and of the id of the div. i believe that a loop is a good thing but i don't know to say each div beagin by T.
thanks.



nb: exuse my poor english.

Animal
4 Mar 2010, 3:25 AM
OK, so you want a tooltip to appear containing different content for each row?

Animal
4 Mar 2010, 3:25 AM
OK, so you want a tooltip to appear containing different content for each row?

Animal
4 Mar 2010, 3:26 AM
Gah! this PHPBB software, or the slow network have been causing all my posts to be doubled!

toto63
4 Mar 2010, 3:35 AM
no not for each row but each cells. but i believe that the difficulty is not here. i done what i what i went to do but i generate a big js because i write code in as file js for each tooltip. like this under * 300

new Ext.ToolTip({
target: 'T1',
autoHeight: true,
autoWidth: true,
autoLoad: {
url: 'T_infobulle.php',
params: 'id=1'
}

i want to reduce my file js like this under. i know that i make différents mistake ..... but i don't understand where ??


var nodes=Ext.query(div,[id^='T']);

Ext.each(nodes,function(id) {

new Ext.ToolTip({
target: 'T'+id,
autoHeight: true,
autoWidth: true,
autoLoad: {
url: 'T_infobulle.php',
params: 'id='+id
}

})


thanks

Animal
4 Mar 2010, 3:41 AM
Use one, single Tooltip instance and use the delegate option to trigger it on each cell.

Modify the content in a beforeshow handler (obviously caching the Ajax-loaded content so that the same cell doesn't load its data more then once)