Skip to content

Service Details

Amit Shuster edited this page Jan 24, 2021 · 6 revisions
ℹ️ This wiki has been deprecated
All our Client APIs documentation and references can be found in the new Power BI embedded analytics Client APIs documentation set.
For the content of this article see Work with a Power BI instance.

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.

  1. 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.

Get a reference to an existing Power BI component given the containing element

var report = powerbi.get(element);

Find the embed instance by unique id or name

var report = powerbi.find('customReportName');

Reset an element

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.