Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo parameterless constructor calls base constructor with parameters

Is it possible in javascript / dojo toolkit to call the base constructor with explicitely set constructor arguments (out of the constructor of the inherited class)

dojo.provide("ClassA");
dojo.declare("ClassA", null,
{
  constructor: function(text)
  {
    console.log(text);
  }
});

dojo.provide("ClassB");
dojo.declare("ClassB", ClassA,
{
   constructor: function()
   {
      // want to call the base constructor of Class A with "Hello "
      console.log("world!");
   }
});

I could use this.inherited(arguments, ["Hello "]) but this will produce two calls of the base constructor (one without and one with the given argument). (will produce output of: undefined\n"Hello "\n"world!").

I already tried using the following ways:

dojo.mixin(this, "Hello");
dojo.safeMixin(this, "Hello");
dojo.mixin(ClassA, "Hello");
...

but all things I did seems to call the base constructor twice. Any suggestions?

like image 932
Beachwalker Avatar asked Jan 18 '26 20:01

Beachwalker


1 Answers

You need to turn off automatic constructor chaing. Take a look here for an example of how to manually override automatic behaviour.

like image 145
emboss Avatar answered Jan 23 '26 09:01

emboss