Ciao a tutti!
Ho una funzione JavaScript:
coloraCella : function() { alert("siii"); },
richiamata da "initialize" in questo modo:
this.coloraCella();
ma firebug mi segnala: IS NOT A FUNCTION
come mai? come posso rosolvere?
Grazie!codice:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Tabella</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="CSS/screen.css" /> <script type="text/javascript" src="./js/prototype.js"></script> <script type="text/javascript"> var EditTable = Class.create(); EditTable.prototype = { t : null, td : null, tr : null, nameClass : null, parametersClass : null, initialize: function () { $$('table')[0].observe( 'click', function (event) { var elt = Event.element(event); if( elt.nodeName == "TD" ) { this.td = elt; //alert("td = " + this.td); this.tr = this.td.up('tr'); //alert("tr = " + this.tr); this.t = this.td.up('table'); //alert("t = " + this.t); this.nameClass = this.t.down().textContent; //alert("nameCLass = " + this.nameClass); //prelevo i parametri var elt_thead = this.t.down('thead'); elt_thead = elt_thead.down('tr'); var par = new Array(); elt_thead.descendants().each(function(s, index) { par[index] = s.textContent; //alert("element : " + par[index]); }); this.parametersClass = par; //alert(this.parametersClass); this.coloraCella(); } //if TD }); //observe table }, //initialize coloraCella : function() { alert("siiii"); } }; var Table = function () { var t = new EditTable; } document.observe("dom:loaded", Table); </script> </head> <body> <table> <caption> CAPTION </caption> <tfoot> <tr> <td>aaaaaa</td> </tr> </tfoot> <thead> <tr> <th> PARAMETRO_1 </th> <th> PARAMETRO_2 </th> </tr> </thead> <tbody> <tr> <td>primo</td> <td>uno</td> </tr> <tr> <td>secondo</td> <td>due</td> </tr> <tr> <td>terzo</td> <td>tre</td> </tr> <tr> <td>quarto</td> <td>quattro</td> </tr> </tbody> </table> </body> </html>

Rispondi quotando
