-
Notifications
You must be signed in to change notification settings - Fork 463
Service Details
As of 2.x Power BI will NOT automatically search your apps DOM for Power BI embed components on page load. If you need this behavior you need to configure the service for this.
To simulate the old behavior you have two options.
- If executing before the DOM is ready you can run the code below which will setup a DOM ready event listener which will call
powerbi.init()
powerbi.enableAutoEmbed();
Otherwise, if your executing after the DOM is ready you can call:
powerbi.init();
This will search for elements with the powerbi-embed-url
attribute and attempt to embed within them using the attribute data.
var report = powerbi.get(element);
var report = powerbi.find('customReportName');
If you have embedded a report within an element and which to reset the element back to it's initial state you can call:
powerbi.reset(element);
This method will remove the embed from the service and remove the iframe which is needed to prevent the service from holding on to reference that doesn't exist in the DOM. It is often needed to call reset before the containing element is removed from the DOM by the parent.