Considering the following Javascript code:
class Component {
  constructor() {
    /* ... */
    this.retrieveContentFromServer()
  }
  retrieveContentFromServer() {
    /* ... */
  }
}
class TextInput extends Component {
  constructor() {
    super()
    this.jqElmt = $('<input type="text" />')
    /* ... */
  }
  retrieveContentFromServer() {
    super.retrieveContentFromServer()
    console.log(this.jqElmt) // undefined
    // this.jqElmt.val(/* ... */)
  }
}
new TextInput()
The console.log(this.jqElmt) returns undefined when a new Object is created from TextInput, which is expected. My goal is to make it return the jQuery object created in the constructor, so that we can edit the text input content retrieved from a server.
So how can I change this piece of code so that:
- Both the constructors of TextInputandComponentare completely executed before any TextInput method is called
- We are able to call a method from the Componentconstructor
I don't know if it's even possible...
