Trying to pass parameter to view model thru iframe

I have an iframe that is loading a view model’s html into the frame on another page.

I get the data via httpClient()'s fetch, and then pass the resulting data to the javascript in the next file.

If I use the following in the html, I get an empty view (no data loaded).

   <iframe src="customer" id="customer" name="customer" align="right"
        style="width:99%; height:93%;">
            </iframe>

Even though I can see that I have data when loading the page, it will not return values to the page.

If I use this, which seems like what I should be using, I get nothing at all.

<iframe src.bind="customer/dbtr.debtor_id" id="dbtr" name="dbtr" align="right"
        style="width:99%; height:93%;">
            </iframe>

How can I successfully pass the parameter debtor_id to the next page so that it will load the data?

1 Like

Perhaps you can use string interpolation here? Something like this (assuming that your viewmodel has a dbtr property that holds an object with a debtor_id property):

<iframe src="customer/${dbtr.debtor_id}"
        id="dbtr" name="dbtr" align="right"
        style="width:99%; height:93%;">
</iframe>

If I would want to use .bind, I think I would have to create an expression that results in the correct url. Something like this:

<iframe src.bind="'customer/' + dbtr.debtor_id"
        id="dbtr" name="dbtr" align="right"
        style="width:99%; height:93%;">
</iframe>

Personally, I prefer the interpolation syntax. It’s shorter and more readable.

2 Likes