Webix 6.1.4 WebixJet 1.6.3 (TypeScript) $scope and deattach event are not available

Hi,
Im evaluating webix 6.1.4 using typescript along with webixjet 1.6.3 . In the documentation its mention use $scope to access view on which widget is based. But, Im unable to find $scope on Jetview. detachEvent is missing in Typescript. Also, how do I access custom methods of one view from another view .
Any help is appreciated

Comments

  • edited January 10

    $scope is the property of a Webix view, not a Jet view. It gives access to the Jet view that includes the Webix view in question, if you call the methods of the former from a simple function:

    { view:"button", click:function(){ this.$scope.SomeMethod() }}
    

    If the function is an arrow one, simply use this:

    { view:"button", click:() => this.SomeMethod() }
    

    It is strongly advisable to access custom class methods from another view ONLY if these views are in a view-subview relation, e.g.:

    import ChildView1 from "./childone";
    class SomeView extends JetView{
      config(){
         return {
            rows:[
               { view:"button", click:(){ this.getSubview().SomeMethod() },
               ChildView1 //this view must have the above method
            ]
         };
      }
    }
    

    or the view-owner of the method is a popup/window created with this.ui():

    import ChildView1 from "./childone";
    class SomeView extends JetView{
      config(){
         return {
            rows:[
               { view:"button", click:(){ this.sub.SomeMethod() }
            ]
         };
      }
      init(){
        this.sub = this.ui(ChildView1); //this view must have the above method
      }
    }
    

    Otherwise, it very much violates one of the key ideas of Jet - keeping views separately and "unaware" of each other.

    As means of communication between arbitrary views, you can have custom JetApp events and services. Both events and services can be accessed by any Jet view regardless of their relations.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion