Consider the following code:
var Widget = new Class({
       Implements: [Options],
       options: {
          "name" : "BaseWidget"
       },
       initialize: function(options) {
          alert("Options are: " + JSON.stringify(options)); //alerts "Options are: undefined"
          this.setOptions(options);
          alert("My options are: " + JSON.stringify(this.options)); //alerts "My options are: { 'name' : 'BaseWidget' }"开发者_开发技巧
       },
       getName: function() {
          return this.options.name;   
       }
});
var LayoutWidget = Widget.extend({    
       initialize: function() {
          this.parent({ "name" : "Layout" });
       }
});
alert(new LayoutWidget().getName()); //alerts "BaseWidget"
I am having difficulty in determining why the argument passed in the "this.parent()" call in "initialize" function of LayoutWidget is coming through as "undefined" in the initialize function of Widget.
I am using MooTools 1.2.2. Would somebody be able to point me in the right direction?
check this: http://www.jsfiddle.net/F4hTS/
slight difference in form.
var Widget = new Class({
    Implements: [Options],
    options: {
        "name" : "BaseWidget"
    },
    initialize: function(options) {
        alert("Options are: " + JSON.stringify(options)); //alerts "Options are: undefined"
        this.setOptions(options);
        alert("My options are: " + JSON.stringify(this.options)); //alerts "My options are: { 'name' : 'BaseWidget' }"
    },
    getName: function() {
        return this.options.name;   
    }
});
Widget.LayoutWidget = new Class({   
    Extends: Widget,
    initialize: function(options) {
        this.parent(options);
    }
});
alert(new Widget.LayoutWidget({ "name" : "Layout" }).getName()); //alerts "Layout"
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论