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>
html5 sapui5 sap-fiori
add a comment |
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>
html5 sapui5 sap-fiori
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 usesap.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
add a comment |
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>
html5 sapui5 sap-fiori
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
html5 sapui5 sap-fiori
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 usesap.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
add a comment |
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 usesap.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
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jun 12 '16 at 9:25
schnoedel
3,0551816
3,0551816
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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