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=function().
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 DynamicTableList("table1", $
{myObject.allFieldsAsJavaScriptArray}, true, true, true);
My javascript class DynamicTableList, note the dtl javascript object
instance variable being referred to in the addRow function. How can I
avoid this???
function DynamicTableList(thisObjName, tableName, options, showDelete,
showUp, showDown)
{
this.processRow = function(r, row, up, down)
{
...
};
this.processRows = function()
{
...
};
this.getVisibility = function(visible)
{
...
};
this.delRow = function(button)
{
...
};
this.addRow = function(selection)
{
...
if (showDelete)
{
var cell2 = document.createElement('TD');
var inp2 = document.createElement('IMG');
/
************************************************** ***********************************************/
inp2.onclick=function(){dtl.delRow(this);} // Have to specify
dtc!!!!!!!!
/
************************************************** ***********************************************/
inp2.title='Delete';
inp2.alt='Delete';
inp2.src='images/delete.gif';
cell2.appendChild(inp2);
row.appendChild(cell2);
}
...
tbody.appendChild(row);
this.processRows();
};
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.