M
Mariano C.
I have a main function (Main) that accept 2 parameters (id_c & id_o),
inside this function another function is called (addEventListener).
Inside addEventListener is declared an anonymous function.
What I would is the possibility to use the above parameter inside this
anonymous function (exactly inside the attachment var). I've write
this, but is uncorrect:
function Main(id_c, id_o) {
var obj = document.getElementById('xyz');
obj.addEventListener(
'click',
function(id_c, id_o)
{
var attachment =
{
'media':
[
{
'type':'image',
'src': 'http://.../img/loghi/
32x32/'+id_c+'.png',
'href': 'http://.../img/loghi/
32x32/'+id_c+'.png'
},
{
'type':'image',
'src':'http://.../loghi/
32x32/'+id_o+'.png',
'href':'http://.../img/loghi/
32x32/'+id_o+'.png'
}
]
};
// ...
return false;
}, false
);
}
PS: if inside anonym function (just before attachment declaration) I
declare id_o and id_c the script is working. Only if I try to pass the
parameter starting from Main function I got an error!
Ideas???
inside this function another function is called (addEventListener).
Inside addEventListener is declared an anonymous function.
What I would is the possibility to use the above parameter inside this
anonymous function (exactly inside the attachment var). I've write
this, but is uncorrect:
function Main(id_c, id_o) {
var obj = document.getElementById('xyz');
obj.addEventListener(
'click',
function(id_c, id_o)
{
var attachment =
{
'media':
[
{
'type':'image',
'src': 'http://.../img/loghi/
32x32/'+id_c+'.png',
'href': 'http://.../img/loghi/
32x32/'+id_c+'.png'
},
{
'type':'image',
'src':'http://.../loghi/
32x32/'+id_o+'.png',
'href':'http://.../img/loghi/
32x32/'+id_o+'.png'
}
]
};
// ...
return false;
}, false
);
}
PS: if inside anonym function (just before attachment declaration) I
declare id_o and id_c the script is working. Only if I try to pass the
parameter starting from Main function I got an error!
Ideas???