Skip to Content
avatar image
Former Member

Delegates in sapui5

Hi,

what is the use of event delegates in sapui5.? I have seen some examples where they use

this.addEventDelegate({

onAfterRendering : function(e)

{

// some logic

}});

My question is already in the controller we have onAfterRendering hook method which we can make use of, why to explicitly use delegates? I am a  newbie please kindly help.

Thanks

Sushmitha

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 27, 2015 at 07:04 AM

    HI Sushmita

    addEventDelegate is for the sapui5 view.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Maksim Rashchynski

      Hi Maksim,

           Thanks for the quick reply.

      Can you please elaborate more with an example?? As I am a newbie, it will be easy for me to understand the concept if you provide an example.

      Thanks,

      Sushmita

  • Oct 27, 2015 at 07:06 AM

    well, answering your question - delegates support cloning which makes them pretty flexible for list binding - you define a delegate for a template and all the "cloned" objects (the way list binding works) will have the same delegate object

    technically this tells you everything

    Element.prototype._handleEvent = function (oEvent) {

      var sHandlerName = "on" + oEvent.type;

      this._callEventHandles(this.aBeforeDelegates.slice(0), sHandlerName, oEvent, true);

      this._callEventHandles([this], sHandlerName, oEvent);

      this._callEventHandles(this.aDelegates.slice(0), sHandlerName, oEvent, true);

    };

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2015 at 07:03 AM

    sdk doc is pretty clear

    SAPUI5 SDK - Demo Kit

    Add comment
    10|10000 characters needed characters exceeded