Skip to content

Service Details

Matt Mazzola edited this page Aug 8, 2016 · 6 revisions

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.

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

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

var report = powerbi.get(element);

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