Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Mootools Class - Calling a function within a function
  2. var Bob = new Class({
  3.  
  4.     initialize: function () {
  5.         this.message = 'Hello';
  6.     },
  7.  
  8.     someOther: function() {
  9.         this.message2 = 'Bob';
  10.     },
  11.  
  12.     getMessage: function() {
  13.         return this.someOther();
  14.     },
  15.  
  16. });
  17.  
  18. window.addEvent('domready', function() {    
  19.     var map = new Bob;
  20.  
  21.     alert(map.getMessage());
  22. });
  23.        
  24. var Bob = new Class({
  25.     initialize: function() {
  26.         this.message = 'Hello';
  27.     },
  28.     someOther: function() {
  29.         return this.message2 = 'Bob'; //bad
  30.     },
  31.     getMessage: function() {
  32.         return this.someOther(); // why
  33.     },
  34. });
  35. window.addEvent('domready', function() {
  36.     var map = new Bob;
  37.     alert(map.getMessage());
  38.     alert(map.message2); // bob
  39. });