possible to call function declared within webix.ui ?

Hi ,
i have a readyuser.js which declared ,

(function(){

var app = {
     LoadDO: function(){
       webix.message("some text!");
     };
   };
})();

and have a html with this code to call the above ,

   webix.ready(function(){
	var appui = {
		type:"space",
		rows:[
			{ view:"readyuser", id:"user1", urls:{
				data:  "debug->dummy"
			}}
		]
	};
	webix.ui({ rows:[ appui ]});
}) ;

so my question is that how can i make a call to the
function declared in the readyuser.js which i wish to
declare it at the same html file of webix.ready but as a separate function,
like the following code ,

 function make_call_to_LoadDO(){
      webix. ?   app.LoadDO();
 };

i need this function to be called by another app
and in turn it will call the LoadDO() declared in my readyuser.js .

Is that possible ? Thanks.

In above code, both files are isolating the code, so you can’t call it directly.
Instead of the direct call, you can use a global event bus

so in readyuser.js you can use

webix.callEvent("LoadDO",[])

and in second file you can use

webix.attachEvent("LoadDO", function(){
   //do something...
})

Hi , thanks maksim,

but after i have done , what happened is that in my html file where i called
the following webix.ready() , it just does not pick up my
my datatable id : picklist declared in readyuser.js ?

(i am not very good in javascript , sorry and excuse me …)

webix.ready(function(){
	var appui = {
		type:"space",
		rows:[
			{ view:"readyuser", id:"user1", urls:{
				data:  "debug->dummy",
				users: "debug->dummy"
			}}
		]
	};
	
	webix.attachEvent("LoadDO", function(){
			webix.message("start LoadDO data...");
			$$("picklist").clearAll();
             //--->picklist of the datatable call will not work , why?
	}) ;
	
	webix.ui({ rows:[ appui ]});

});

Do appreciate you can advise some more .

Hi,

The code itself is valid, the issue can be caused by

  • using “isolate:true” in the ready user, which makes component not accessible to the by-id calls.

  • timing issue, it is possible that LoadDO event is called when the related datatable is not created yet