Reputation: 83
Note:- i want to call ClassA function "deleteEntryInternal" in another class B within "afterRequest function. how can i call this function in other class function.
My code is Below //here is my Class A
Ext.define('WebCare.UI.OtherServicesEditor', {
extend: 'Ext.WebCare.UI.BaseEditor',
_otherservicesGrid: null,
alias: 'widget.otherserviceseditor',
title: 'Other Services',
defaultType: 'textfield',
id: 'otherservicesEditor',
deleteEntryInternal: function (isDelete) {
this.disableForm();
var self = this;
var selection = self._otherservicesGrid.getSelectionModel().getSelection();
if (selection.length > 0) {
if (isDelete) {
selection[0].data.IsDelete = true;
}
this.deleteServerRecord(selection[0].data, function () { });
vent.trigger(otherServicesStore.storeId, selection[0].data);
}
}
Upvotes: 0
Views: 1590
Reputation: 873
It is never a good idea to cross reference class methods on any way. Although Harshal's methods will work it is just very bad app design. If your class needs to react to an event what is happening in another class then why don't you just fire an event in class A and set up a listener in class B?
Upvotes: -1
Reputation: 946
To call this method, you need to obtain instance of this class. And then you can call methods in that class.
1.You can get an instance of Ext.app.Controller by
var controllerInstance = appName.app.getController('appName.controller.controllerName');
controllerInstance.methodToCall();
where appName is name of your Extjs App.
2.If your class is a view which is already rendered , you can get its instance by -
var viewInstance = Ext.getCmp(viewId);
viewInstance.methodToCall();
where viewId is id of your view.
3. Static class - You can call methods of static class directly like if class MyStaticClass is static class , you can call its methods like -
MyStaticClass.methodToCall();
Upvotes: 2