on 01-11-2018 6:46 PM
Hello,
I am trying to find a way to insert Javascript Code within XML View. Below code is an example, where we need to display a custom tooltip based on a custom or third party library. We can do this in controller file by adding event delegate. But for having tooltip for many UI controls, having separate methods might take more code/time. Whereas, if there is a way within XML, it will be simple to invoke a single line additional code. Please point with some examples as well.
new Button({
text: "mouseover Here",
icon: "sap-icon://cursor-arrow",
iconFirst: false,
type: ButtonType.Transparent,
tooltip: new MyTooltip({
text: "Awesome!"
}),
})
Thanks and Regards.
Try this approach...
For each button, you can add an `id` in the XML file. In the OnInit Method, you can add the tooltips with a single line of code like below...
this.byId("idbtn").setTooltip("This is Test")
Also if you have multiple views which need tooltips you could move this code into a common utility file for re-usability...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It is not a standard / good practice to write your JS code inside an XML view, as XML views support strictly an MVC architecture. I would recommend that, you set the tooltip for your controls in the init function of your controller.
Regards,
Arjun Biswas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://blogs.sap.com/2016/07/18/how-to-create-a-custom-ui5-control/
probably you don't need js in xml
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.