Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ajelcocks
Frequent Visitor

page events not firing

I have installed powerbi report server developer edition locally per instructions here https://docs.microsoft.com/en-us/power-bi/report-server/install-report-server

I downloaded power bi desktop fior RS per the instructions

Then I created a simple report.

Finally I created a very simple web page in VS Code and launched it using lite-server. 

 

html is:

<html>
  <head>
    <script src="./dist/powerbi.js"></script>
    <script src="./dist/bundle.js"></script>
  </head>
  <body>
    <h3>powerbi lite</h3>
    <button id="pageButton">getPage</button>
    <div id="charts">charts</div>
  </body>
</html>
 
javascript is
 
window.onload = start;

const PBI_URL = "http://localhost:4010/powerbi/";
const REPORT_ID = "39af5e1d-c919-4594-ad6a-ee772f734d3d";

let reportUrl = `${PBI_URL}?rs:embed=true&id=${REPORT_ID}&formatLocale=en-US`;

function start() {
  let container = document.getElementById("charts");
  let models = window["powerbi-client"].models;

  var config = {
    type: "report",
    tokenType: models.TokenType.Embed,
    accessToken: "123",
    embedUrl: reportUrl,
    id: REPORT_ID,
    permissions: models.Permissions.All,
    settings: {
      filterPaneEnabled: true,
      navContentPaneEnabled: true
    }
  };

  let report = window.powerbi.embed(containerconfig);

  report.on("loaded"function() {
    console.log("Report loaded");
  });

  document.getElementById("pageButton").onclick = getPage;
}

function getPage() {
  let container = document.getElementById("charts");
  let report = window.powerbi.get(container);
  report.eventHandlers[0].handle();
  report.getPages().then(function(pages) {
    console.log(pages);
  });
 
}
The page loades in a iframe created in the container, as expected, but the loaded event doesnt fire.
 
I also add a button as a trigger to invoke some code manually, i.e. function getPage()
 
This shows the handler was added as the invocation of handle() prints to console.
 
However, The promise of report.getPages() does not fire.
 
It seems none of the mesages pushed are firing.
I ran fiddler and no api calls are registered when I click the button.
 
Does anyone have experience with this? or knowledge of a resource I can leverage?
Thanks 🙂
0 REPLIES 0

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.