<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replace replace current embedded report with new one on same page in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/162595#M5447</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/18467"&gt;@tylersbrown01&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say I'm making a single page application and a user requests to see a new report. I want to be able to reload a new report into the existing &amp;lt;div id="report-container"&amp;gt; element.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when i call the embed(config, report-container) method on a div element that ALREADY has a report embedded onto it, I receive the following error (reduced for brevity):&lt;/P&gt;
&lt;PRE&gt;...which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.
Error: Attempted to embed using config &lt;/PRE&gt;
&lt;P&gt;Is there any way I can "re-embed" or do I need to destroy the current div and generate a new one? What's the best workflow to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/18467"&gt;@tylersbrown01&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It is possible to re-embed another report. You can call&amp;nbsp;powerbi.embedNew with a new configuration file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;html&amp;gt;

 &amp;lt;script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"&amp;gt;&amp;lt;/script&amp;gt;  
 &amp;lt;script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js""&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
var embedConfiguration = {
    type: 'report',
    accessToken: 'token',
    id: 'reportid',
    embedUrl: 'https://app.powerbi.com/reportEmbed?reportId=reportid' 
}; 

var report;

window.onload = function () { 

var $reportContainer = $('#reportContainer');
 
 report= powerbi.embed($reportContainer.get(0), embedConfiguration);
 
} 


&lt;STRONG&gt;function reloadreport(){ 

var $reportContainer = $('#reportContainer');
powerbi.embedNew($reportContainer.get(0), embedConfiguration);

}&lt;/STRONG&gt;;
&amp;lt;/script&amp;gt;

&amp;lt;button onclick="reloadreport()"&amp;gt;Click me to reload&amp;lt;/button&amp;gt;
&amp;lt;div id="reportContainer"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;/html&amp;gt;  
 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2017 09:09:26 GMT</pubDate>
    <dc:creator>Eric_Zhang</dc:creator>
    <dc:date>2017-04-21T09:09:26Z</dc:date>
    <item>
      <title>Replace replace current embedded report with new one on same page</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/161556#M5425</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say I'm making a single page application and a user requests to see a new report. I want to be able to reload a new report into the existing &amp;lt;div id="report-container"&amp;gt; element.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i call the embed(config, report-container) method on a div element that ALREADY has a report embedded onto it, I receive the following error (reduced for brevity):&lt;/P&gt;&lt;PRE&gt;...which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.
Error: Attempted to embed using config &lt;/PRE&gt;&lt;P&gt;Is there any way I can "re-embed" or do I need to destroy the current div and generate a new one? What's the best workflow to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 22:41:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/161556#M5425</guid>
      <dc:creator>tylersbrown01</dc:creator>
      <dc:date>2017-04-19T22:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replace replace current embedded report with new one on same page</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/162595#M5447</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/18467"&gt;@tylersbrown01&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say I'm making a single page application and a user requests to see a new report. I want to be able to reload a new report into the existing &amp;lt;div id="report-container"&amp;gt; element.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when i call the embed(config, report-container) method on a div element that ALREADY has a report embedded onto it, I receive the following error (reduced for brevity):&lt;/P&gt;
&lt;PRE&gt;...which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.
Error: Attempted to embed using config &lt;/PRE&gt;
&lt;P&gt;Is there any way I can "re-embed" or do I need to destroy the current div and generate a new one? What's the best workflow to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/18467"&gt;@tylersbrown01&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It is possible to re-embed another report. You can call&amp;nbsp;powerbi.embedNew with a new configuration file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;html&amp;gt;

 &amp;lt;script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"&amp;gt;&amp;lt;/script&amp;gt;  
 &amp;lt;script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js""&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
var embedConfiguration = {
    type: 'report',
    accessToken: 'token',
    id: 'reportid',
    embedUrl: 'https://app.powerbi.com/reportEmbed?reportId=reportid' 
}; 

var report;

window.onload = function () { 

var $reportContainer = $('#reportContainer');
 
 report= powerbi.embed($reportContainer.get(0), embedConfiguration);
 
} 


&lt;STRONG&gt;function reloadreport(){ 

var $reportContainer = $('#reportContainer');
powerbi.embedNew($reportContainer.get(0), embedConfiguration);

}&lt;/STRONG&gt;;
&amp;lt;/script&amp;gt;

&amp;lt;button onclick="reloadreport()"&amp;gt;Click me to reload&amp;lt;/button&amp;gt;
&amp;lt;div id="reportContainer"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;/html&amp;gt;  
 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 09:09:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/162595#M5447</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-04-21T09:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Replace replace current embedded report with new one on same page</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/162911#M5456</link>
      <description>&lt;P&gt;Thanks Eric. I actually figured it out using&amp;nbsp;&lt;SPAN&gt;with&amp;nbsp;&lt;SPAN&gt;powerbi.reset(element);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From the documentation...&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"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."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 22:11:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/162911#M5456</guid>
      <dc:creator>tylersbrown01</dc:creator>
      <dc:date>2017-04-21T22:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Replace replace current embedded report with new one on same page</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/484595#M14871</link>
      <description>&lt;P&gt;Here's an answer for anyone using Angular 2+ and Typescript in a component:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;// import *&amp;nbsp; as pbi from 'powerbi-client';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;// let config = { ... }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;let reportContainer = &amp;lt;HTMLElement&amp;gt;document.getElementById("reportEmbedded");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;// Embed the report and display it within the div container.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;let powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;powerbi.reset(reportContainer);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;let report = &amp;lt;pbi.Report&amp;gt;powerbi.embed(reportContainer, config);&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 02:28:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replace-replace-current-embedded-report-with-new-one-on-same/m-p/484595#M14871</guid>
      <dc:creator>sdaviesnz</dc:creator>
      <dc:date>2018-08-09T02:28:06Z</dc:date>
    </item>
  </channel>
</rss>

