How to trigger click event for html anchor tag on xml view SAP UI5











up vote
0
down vote

favorite












I am trying to combine XMLView & standard html. On xml view, we can use press="onDoSomething" attribute & onDoSomething : function(){} on app.controller.js to trigger click event. But how to trigger it on html. Here is my code



<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="banalyzer.controller.App" xmlns:html="http://www.w3.org/1999/xhtml"
displayBlock="true">
<App id="BA_APP">
<pages>
<HBox width="100%" height="100%" id="header_container">
<items>
<Image class="logo" src="../images/logo_new.png"/>
<Image class="header" src="../images/header-bg.png"/>
</items>
<html:ul class="tab">
<html:li>
<html:a href="#" onclick="onBud()" class="tablinks active">Budget Analyzer</html:a>
</html:li>
<html:li>
<html:a href="#" onclick="spend()" class="tablinks">Spend Analyzer</html:a>
</html:li>
</html:ul>
</HBox>
</pages>
</App>
</mvc:View>









share|improve this question
























  • Not sure how to solve this -- I have never tried using event handlers from standard HTML inside SAPUI5 other than browser events such as click, drag etc -- but why not simply use sap.m.Link instead? See sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html
    – Qualiture
    Jun 10 '16 at 13:51










  • Thanks!. I am a newbie to SAPUI5. I was just trying to explore how html works on sapui5.
    – Hari
    Jun 14 '16 at 7:00















up vote
0
down vote

favorite












I am trying to combine XMLView & standard html. On xml view, we can use press="onDoSomething" attribute & onDoSomething : function(){} on app.controller.js to trigger click event. But how to trigger it on html. Here is my code



<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="banalyzer.controller.App" xmlns:html="http://www.w3.org/1999/xhtml"
displayBlock="true">
<App id="BA_APP">
<pages>
<HBox width="100%" height="100%" id="header_container">
<items>
<Image class="logo" src="../images/logo_new.png"/>
<Image class="header" src="../images/header-bg.png"/>
</items>
<html:ul class="tab">
<html:li>
<html:a href="#" onclick="onBud()" class="tablinks active">Budget Analyzer</html:a>
</html:li>
<html:li>
<html:a href="#" onclick="spend()" class="tablinks">Spend Analyzer</html:a>
</html:li>
</html:ul>
</HBox>
</pages>
</App>
</mvc:View>









share|improve this question
























  • Not sure how to solve this -- I have never tried using event handlers from standard HTML inside SAPUI5 other than browser events such as click, drag etc -- but why not simply use sap.m.Link instead? See sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html
    – Qualiture
    Jun 10 '16 at 13:51










  • Thanks!. I am a newbie to SAPUI5. I was just trying to explore how html works on sapui5.
    – Hari
    Jun 14 '16 at 7:00













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to combine XMLView & standard html. On xml view, we can use press="onDoSomething" attribute & onDoSomething : function(){} on app.controller.js to trigger click event. But how to trigger it on html. Here is my code



<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="banalyzer.controller.App" xmlns:html="http://www.w3.org/1999/xhtml"
displayBlock="true">
<App id="BA_APP">
<pages>
<HBox width="100%" height="100%" id="header_container">
<items>
<Image class="logo" src="../images/logo_new.png"/>
<Image class="header" src="../images/header-bg.png"/>
</items>
<html:ul class="tab">
<html:li>
<html:a href="#" onclick="onBud()" class="tablinks active">Budget Analyzer</html:a>
</html:li>
<html:li>
<html:a href="#" onclick="spend()" class="tablinks">Spend Analyzer</html:a>
</html:li>
</html:ul>
</HBox>
</pages>
</App>
</mvc:View>









share|improve this question















I am trying to combine XMLView & standard html. On xml view, we can use press="onDoSomething" attribute & onDoSomething : function(){} on app.controller.js to trigger click event. But how to trigger it on html. Here is my code



<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="banalyzer.controller.App" xmlns:html="http://www.w3.org/1999/xhtml"
displayBlock="true">
<App id="BA_APP">
<pages>
<HBox width="100%" height="100%" id="header_container">
<items>
<Image class="logo" src="../images/logo_new.png"/>
<Image class="header" src="../images/header-bg.png"/>
</items>
<html:ul class="tab">
<html:li>
<html:a href="#" onclick="onBud()" class="tablinks active">Budget Analyzer</html:a>
</html:li>
<html:li>
<html:a href="#" onclick="spend()" class="tablinks">Spend Analyzer</html:a>
</html:li>
</html:ul>
</HBox>
</pages>
</App>
</mvc:View>






html5 sapui5 sap-fiori






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 3:16









Cœur

17k9102140




17k9102140










asked Jun 10 '16 at 12:42









Hari

671618




671618












  • Not sure how to solve this -- I have never tried using event handlers from standard HTML inside SAPUI5 other than browser events such as click, drag etc -- but why not simply use sap.m.Link instead? See sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html
    – Qualiture
    Jun 10 '16 at 13:51










  • Thanks!. I am a newbie to SAPUI5. I was just trying to explore how html works on sapui5.
    – Hari
    Jun 14 '16 at 7:00


















  • Not sure how to solve this -- I have never tried using event handlers from standard HTML inside SAPUI5 other than browser events such as click, drag etc -- but why not simply use sap.m.Link instead? See sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html
    – Qualiture
    Jun 10 '16 at 13:51










  • Thanks!. I am a newbie to SAPUI5. I was just trying to explore how html works on sapui5.
    – Hari
    Jun 14 '16 at 7:00
















Not sure how to solve this -- I have never tried using event handlers from standard HTML inside SAPUI5 other than browser events such as click, drag etc -- but why not simply use sap.m.Link instead? See sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html
– Qualiture
Jun 10 '16 at 13:51




Not sure how to solve this -- I have never tried using event handlers from standard HTML inside SAPUI5 other than browser events such as click, drag etc -- but why not simply use sap.m.Link instead? See sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html
– Qualiture
Jun 10 '16 at 13:51












Thanks!. I am a newbie to SAPUI5. I was just trying to explore how html works on sapui5.
– Hari
Jun 14 '16 at 7:00




Thanks!. I am a newbie to SAPUI5. I was just trying to explore how html works on sapui5.
– Hari
Jun 14 '16 at 7:00












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










The html elements are copied by the XMLView into the page on rendering of the View. As they are not UI5 controls but html dom elements, the events and properties will not be processed. So the code in your onclick events will be copied untouched to the output page.



When the user clicks on such a link, the code will be executed in the global window context. There is no easy way to find the UI5 View instance that has rendered the link and its Controller instance where your want to call a method.



The easyest way to attach html events to a controller method would be to give the html elements an id and bind the events in your controllers onAfterRendering method:



  onAfterRendering:function(){
jQuery("#"+this.createId("link1")).on("click",this.onLinkPressed.bind(this));
jQuery("#"+this.createId("link2")).on("click",this.onLinkPressed.bind(this));
},


Example on JSBin.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37748599%2fhow-to-trigger-click-event-for-html-anchor-tag-on-xml-view-sap-ui5%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    The html elements are copied by the XMLView into the page on rendering of the View. As they are not UI5 controls but html dom elements, the events and properties will not be processed. So the code in your onclick events will be copied untouched to the output page.



    When the user clicks on such a link, the code will be executed in the global window context. There is no easy way to find the UI5 View instance that has rendered the link and its Controller instance where your want to call a method.



    The easyest way to attach html events to a controller method would be to give the html elements an id and bind the events in your controllers onAfterRendering method:



      onAfterRendering:function(){
    jQuery("#"+this.createId("link1")).on("click",this.onLinkPressed.bind(this));
    jQuery("#"+this.createId("link2")).on("click",this.onLinkPressed.bind(this));
    },


    Example on JSBin.






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      The html elements are copied by the XMLView into the page on rendering of the View. As they are not UI5 controls but html dom elements, the events and properties will not be processed. So the code in your onclick events will be copied untouched to the output page.



      When the user clicks on such a link, the code will be executed in the global window context. There is no easy way to find the UI5 View instance that has rendered the link and its Controller instance where your want to call a method.



      The easyest way to attach html events to a controller method would be to give the html elements an id and bind the events in your controllers onAfterRendering method:



        onAfterRendering:function(){
      jQuery("#"+this.createId("link1")).on("click",this.onLinkPressed.bind(this));
      jQuery("#"+this.createId("link2")).on("click",this.onLinkPressed.bind(this));
      },


      Example on JSBin.






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        The html elements are copied by the XMLView into the page on rendering of the View. As they are not UI5 controls but html dom elements, the events and properties will not be processed. So the code in your onclick events will be copied untouched to the output page.



        When the user clicks on such a link, the code will be executed in the global window context. There is no easy way to find the UI5 View instance that has rendered the link and its Controller instance where your want to call a method.



        The easyest way to attach html events to a controller method would be to give the html elements an id and bind the events in your controllers onAfterRendering method:



          onAfterRendering:function(){
        jQuery("#"+this.createId("link1")).on("click",this.onLinkPressed.bind(this));
        jQuery("#"+this.createId("link2")).on("click",this.onLinkPressed.bind(this));
        },


        Example on JSBin.






        share|improve this answer












        The html elements are copied by the XMLView into the page on rendering of the View. As they are not UI5 controls but html dom elements, the events and properties will not be processed. So the code in your onclick events will be copied untouched to the output page.



        When the user clicks on such a link, the code will be executed in the global window context. There is no easy way to find the UI5 View instance that has rendered the link and its Controller instance where your want to call a method.



        The easyest way to attach html events to a controller method would be to give the html elements an id and bind the events in your controllers onAfterRendering method:



          onAfterRendering:function(){
        jQuery("#"+this.createId("link1")).on("click",this.onLinkPressed.bind(this));
        jQuery("#"+this.createId("link2")).on("click",this.onLinkPressed.bind(this));
        },


        Example on JSBin.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 12 '16 at 9:25









        schnoedel

        3,0551816




        3,0551816






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37748599%2fhow-to-trigger-click-event-for-html-anchor-tag-on-xml-view-sap-ui5%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine