cancel
Showing results for 
Search instead for 
Did you mean: 

How to use attachEvent() correctly

0 Kudos

Hi,

the following question raised up only because we are/must using the sap.ui.core.Message in a ux3.Shell as this is mandatory for the notification bar. Our use case want to have the functionality to react on the click event of the message. The message itself does not have a pre-defined event "press".

Therefore I think about to add a common event "onclick" via "attachEvent". My approach fails currently on I would like to understand, what needs to be done.

My code looks like this:

     var oMessageNotifier = new sap.ui.ux3.Notifier( {
            title : "Your system messages"
         });
        oNotr.addNotifier(oMessageNotifier);

        oNotiBar.setVisibleStatus(sap.ui.ux3.NotificationBarStatus.Default);

        var error   = new sap.ui.core.Message("msg", {text:"fooBuh"});
       
        error.attachEvent("onclick",function(event){alert('foo');});
        oMessageNotifier.addMessage(error);

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Ok. The way to fetch events of message selection inside of a NotificationBar is:

...view.js

{....

     create.content = function(){

          ...

    function clickListener(oEvent) {
   var oMessage = oEvent.getParameter("message");
   alert("Message selected: " + oMessage.url());
   };

...

     oNotifier2.attachMessageSelected(clickListener);    

          ...

     }

}

Former Member
0 Kudos

Hi Janko,

You can get the object by jQuery using the id, and then set the event "onclick"

http://api.jquery.com/category/events/

Regards,

Jose Manuel