I am trying to define a base class in JavaScript that performs many common functions when created. Part of this function is to create a component and register callback handlers for that component.
The problem is how to override the function that is used for this callback handler in child classes that extend my base class.
In specific terms, I have a component BasicPagethat creates a component Table. BasicPagealso defines the default function onRowClickthat is registered at creation Table.
Now I want to create a component PageWithSectionsthat extends BasicPage(via an operator call(..)) and overrides onRowClick. The problem is registering the click handler when the table is executed inside the base class constructor. During this registration, it onRowClickhas not yet been redefined, so the link refers to the version of the base classes onRowClick.
I created jsBin that illustrates the problem.
http://jsbin.com/uDEjuzeQ/9/edit
If you click on each box once, in order, I want the message box to be displayed:
Currently there are no messages; row pressed; row pressed; BasicPage onRowClicked; row pressed; PageWithSections onRowClicked
What is the correct way to override a function in the constructor chain and associate an overridden function with something while building the base object?
UPDATE
, , , .
, . .