Skip to Content

Is it possible to use addEventDelegate for register onAfterRendering for entire view instead of individual controls?

example: i have  in my page i have 3 tables like oTable1,oTable2,oTable3 and some other openui5 controls.

now      oTable1.addEventDelegate({

           onAfterRendering: function(){

                    alert(" table1 rendered");

          }

          }, this);

instead of doing similer things to all controls .can i do for entire page

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Oct 16, 2015 at 06:06 AM

    yes, you can. Just add the delegate in your view instance. In the onInit of the controller, you can do as below.

    this.getView().addEventDelegate({
         onAfterRendering : function(){
              console.log("view rendered");
         }
    });
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2015 at 06:04 AM

    I am not sure if I understand your problem right, but the views already have an event called onAfterRendering that does not need to be added manually.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 16, 2015 at 08:26 AM

    Hi,

    Can you check this link, After render table, it throws alert.

    link: JS Bin - Collaborative JavaScript Debugging

    Add comment
    10|10000 characters needed characters exceeded

    • Please do not use Pradeep's solution.

      He is overriding the table onAfterRendering function, where he does

      oTable.onAfterRendering = function() {

      ...

      };

      From the jsbin, you can see that the table is not rendered correctly.

      Thanks

      -D

  • Oct 18, 2015 at 08:52 AM

    I don't think it is possible to move all your addEventDelegate functions from each control to one place.

    The only way I can think of  - is to use onAfterRendering function of the controller, but even then you'll have to call each desired control by its id, which doesn't seem like a good idea.

    Cheers.

    Add comment
    10|10000 characters needed characters exceeded