Skip to Content

How to trigger two functions with single button press in UI5

Hi All,

could you please say how to trigger two functions from single button press in SAP UI5 button [Requesting in xml view].

Controller.js

onPress1: function () {

console.log( " 1 Pressed");

},

onPress2: function () {

console.log( "2 Pressed");

},

View.xml(following is working when seperate buttons)

<Button press="onPress1"/>

<Button press="onPress2"/>

View.xml(following is Not working)

<Button press="onPress1 ; onPress1"/>

could you please say where I am going wrong...

Note:for my scenario function2 calling inside function1 will not workout.

Could you please suggest any other solution for XML view.

Thanks in advance,

regards,

Abhiram.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Oct 22, 2015 at 06:28 PM

    why dont create

    onPress12 : fucntion()

    {

    this.onPress1();

    this.onPress2();

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 23, 2015 at 05:22 AM

    Hi Nalam,

    Will this help? JS Bin - Collaborative JavaScript Debugging

    Thanks,

    Karthik A

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 23, 2015 at 05:58 AM

    How about this?

    In xml

    <Button id = "buttonid" class = "buttonclass" ></Button>

    In controller

    onAfterRendering : function()

    {

    var id = this.getView().byId("buttonid").sId;

    $("#" + id).bind("click" , function () { alert("function one")});

    $(".buttonclass").bind("click" , function () { alert("function two")})


    }

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.