-
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 application's DOM for Power BI embed components on page load. If you need this behavior you must 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 to set up a DOM ready event listener, which will call
powerbi.init()
powerbi.enableAutoEmbed();
Otherwise, if you're 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 want to reset the element back to its initial state, call:
powerbi.reset(element);
This method removes the embed from the service and removes the iframe (required to prevent the service from holding on to reference that doesn't exist in the DOM). You typically need to call reset before the containing element is removed from the DOM by the parent.