I develop the custom visuals.
I add click event on element
And I want to call update manually update method (to refresh )
It worked when I use power bi online for developping
But it not work when package that.
Asked
Active
Viewed 906 times
0

NoDirection
- 122
- 4
- 11
1 Answers
0
You can use jQuery in your custom visual to do that. In Simple terms see the below code. In this example I created an element then you can create a jQuery 'on' section to call the update method.
private $root: JQuery;
public update(options: VisualUpdateOptions) {
this.$root = $("#sandbox-host"); // Main container inside iframe of visual
this.$root.append(`<div id="myElement" class="element"></div>`);
$("#myElement").on("click", () => {
this.update(this.options);
});
}
Make sure to use => operator with "click" as it will give you "this" access of Class.
Second, don't forget to add jQuery libs in your dependencies of package.json. Add them and run npm install.
"jquery": "^3.2.1",
"@types/jquery": "^2.0.41",
Once done, you can use jQuery in your visual.ts and other files.
Note - You can also add checks in your update() method using if conditions so you only execute required code on manually calling update() method.

Aakash Kumar
- 893
- 4
- 15
- 38