WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Re:Adding functions with object prototyping , Wellington, September 29, 2003

Subject: Re:Adding functions with object prototyping From: Wellington Date: September 29, 2003

Exists other techinique, which I appreend with Eric codes. The inconveience is that all functions that attach events should do that.

However this minimizes the code size. You also can do:

<script type="text/javascript">
 nodes = new Array();
 count = 0;
 function node(label,parentNode){
  this.label = label;
  this.parentNode = parentNode;
 node.prototype.add = function(){
  this.newNode = document.createElement("DIV");
  this.newNode.className = 'node';
  this.newNode.innerHTML = 'new node' + count;

  var oThis = this; //the var is required because if exist other oThis variable the scope will do the difference of them

   this.newNode.onclick = function(){


  this.newNode.attachEvent("onclick", function(){


 node.prototype.remove = function(){

       //to test
  window.onload = function(){
      A = new node('AAAA', document.body); 
      AB = new node('AAAA', A.newNode); 
      AC = new node('AAAA', A.newNode); 
      AD = new node('AAAA', A.newNode);



Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.

View All Messages
Back to WebFX