BUG: $scope == null when using webix.addView(...)

I am dynamically adding a button with the function webix.addView()

But then, inside the button’s click handler the variable this.$scope is null.

If I stataically include the same button into the layout, then $scope variable is set correctly

Hello,

It is not a bug.
The point is that addView uses regular webix.ui pattern of view initialization which does not work with the Jet scope.
In Jet, two options are assumed:

  • buttons/small pieces of UI are initialized yet hidden initially;
  • bigger parts of UI are initialized as separate modules and can be hidden/placed into the $subview

If your use-case cannot be implemented with the above options, can you please share the scenario?

However, we will extend this.ui method to provide a feature similar to addView.

if a component is child of an accordionitem, then $scope is not passed to that component as well.

if a component is child of an accordionitem

Will be fixed in the next Webix update (the issue is related to the main library)

However, we will extend this.ui method

The solution is much simpler.
Instead adding new parameters to this.ui, it is possible to use just

some.addView({ $scope: this, /* the rest of config */ })

So the .ui method will not be changed.

The related snippet - https://webix.com/snippet/ade0ba57