I have a javascript object which dynamically generates a table adding,
deleting and moving rows as the user clicks on buttons or links.
Problem is when I generate a table row and add the javascript method
call to my class, I have to put the object instance name variable of
the class in order for it to be called from the onclick=functio n().
This is seriously limiting, but I'm stuck for a way round it. Heres a
edited of the code so you get the idea....
Instantiating the object :-
var dtl = new DynamicTableLis t("table1", $
{myObject.allFi eldsAsJavaScrip tArray}, true, true, true);
My javascript class DynamicTableLis t, note the dtl javascript object
instance variable being referred to in the addRow function. How can I
avoid this???
function DynamicTableLis t(thisObjName, tableName, options, showDelete,
showUp, showDown)
{
this.processRow = function(r, row, up, down)
{
...
};
this.processRow s = function()
{
...
};
this.getVisibil ity = function(visibl e)
{
...
};
this.delRow = function(button )
{
...
};
this.addRow = function(select ion)
{
...
if (showDelete)
{
var cell2 = document.create Element('TD');
var inp2 = document.create Element('IMG');
/
*************** *************** *************** *************** *************** *************** *******/
inp2.onclick=fu nction(){dtl.de lRow(this);} // Have to specify
dtc!!!!!!!!
/
*************** *************** *************** *************** *************** *************** *******/
inp2.title='Del ete';
inp2.alt='Delet e';
inp2.src='image s/delete.gif';
cell2.appendChi ld(inp2);
row.appendChild (cell2);
}
...
tbody.appendChi ld(row);
this.processRow s();
};
this.moveRow = function(node, vector)
{
};
}
Obviously the code dtl.delRow(this ); is being dynamically generated,
but how do I replace the dtl instance name with something that'll work
whatever the user of this class calls the instance of it!
Cheers, in advance for any help.
Philip Wilkinson.