Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
godd4k
Regular Visitor

Events only triggered once [Dashboard confirmed]

I've started implementing some functionality using the tileClicked event on an embedded dashboard, it works great but the event is only triggered once and then never again.

 

Here's a watered down version of things I used for a sanity check:

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('tile clicked event', event);
});

This will log once but never again.

1 ACCEPTED SOLUTION

@v-ljerr-msft

I should have updated this post, the problem was actually that empty DOM elements were infront of my dashboard element and so I was never actualy clicking on the tile after the first time (where they get added), it just looked like it. Bit of a rookie mistake really, I clearly wasn't thinking but it's all working now.

FYI though, you are able to have multiple listeners for the same event on an element.

For example

 

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('tile clicked event', event);
});
embeddedDashboard.on('tileClicked', function (event) {
console.log('I would log after the above console log');
});

 

Using off

 

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('You will never see me', event);
});
embeddedDashboard.off('tileClicked);
embeddedDashboard.on('tileClicked', function (event) {
console.log('You would see me though!');
});

 

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('You will never see me', event);
});
embeddedDashboard.on('tileClicked', function (event) {
console.log('Or me!');
});
embeddedDashboard.off('tileClicked');

 

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @godd4k,

 

According to your description above, I just tested the tileClicked event with Microsoft Power BI Embedded Sample. And the tileClicked event can be triggered more that once(every time I clicked a tile on the dashboard).

 

I assume you may need to firstly remove the tileClicked event handler if it already exists to make it work in this scenario.Smiley Happy

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
//.off removes a given event handler if it exists. embeddedDashboard.off("tileClicked"); embeddedDashboard.on('tileClicked', function (event) { console.log('tile clicked event', event); });

 

Regards

@v-ljerr-msft

I should have updated this post, the problem was actually that empty DOM elements were infront of my dashboard element and so I was never actualy clicking on the tile after the first time (where they get added), it just looked like it. Bit of a rookie mistake really, I clearly wasn't thinking but it's all working now.

FYI though, you are able to have multiple listeners for the same event on an element.

For example

 

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('tile clicked event', event);
});
embeddedDashboard.on('tileClicked', function (event) {
console.log('I would log after the above console log');
});

 

Using off

 

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('You will never see me', event);
});
embeddedDashboard.off('tileClicked);
embeddedDashboard.on('tileClicked', function (event) {
console.log('You would see me though!');
});

 

var embeddedDashboard = powerbi.embed({{myElem}}, {{myConfig}});
embeddedDashboard.on('tileClicked', function (event) {
  console.log('You will never see me', event);
});
embeddedDashboard.on('tileClicked', function (event) {
console.log('Or me!');
});
embeddedDashboard.off('tileClicked');

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.