I have a dynamic page with everything set up properly, I think. It was working fine until I added some code to the page. I wanted to have part of the label in a button connected to a dataset. It was all fine after I finished the code for one of the two buttons. But after the second button, every text, image, and other stuff connected to the dataset started being the same thing. It said the exact same thing on each page. The buttons were working fine, but everything else wasn’t. Does anyone have a fix for this?
Here is the code I have on the dynamic page
$w.onReady(function () {
$w.onReady( () => {
$w("#dynamicDataset").onReady( () => {
let title= $w("#dynamicDataset").getCurrentItem().title;//text is the field you want to get its text
$w("#button2").label = title + "'s Website" ;
});
});
$w.onReady( () => {
$w("#dynamicDataset").onReady( () => {
let title= $w("#dynamicDataset").getCurrentItem().title;//text is the field you want to get its text
$w("#button1").label = title + "'s Zomato Page"
});
});
});
The page onReady() event handler triggers once, when the page is ready. In your case, you have two onReady() functions inside yet another onReady() function. Neither of those two onReady() functions will execute. A page should have only one onReady() function which should contain all of the code that should be executed when the page is ready.
✓ For more information, see the page onReady() API.
Furthermore, you have two dataset onReady() functions “hidden” inside of the invalid page onReady() functions. The dataset onReady() event handler is triggered once, when the dataset if ready. You should have only one dataset onReady() in your page onReady() function, which should contain all of the code that should be executed when the dataset is ready.
✓ For more information see the dataset onReady() API.
Your code should look something like this:
$w.onReady(function () {
$w("#dynamicDataset").onReady( () => {
let title = $w("#dynamicDataset").getCurrentItem().title;
$w("#button2").label = title + "'s Website" ;
$w("#button1").label = title + "'s Zomato Page"
});
});
Note: this code has not been tested and is for illustration only.
Thanks so much, Yisrael. However, now I need some more code that can connect the content manager to an HTML frame.
Here is that code:
export function html1_message(event) { let urlMessage = $w('#dynamicDataset').getCurrentItem().htmlmap; $w("#html1").onMessage( (event) => { $w("#html1").postMessage(urlMessage); }); }
Here is all the code from that page:
// For full API documentation, including code examples, visit https://wix.to/94BuAAs export function html1_message(event) { let urlMessage = $w('#dynamicDataset').getCurrentItem().htmlmap; $w("#html1").onMessage( (event) => { $w("#html1").postMessage(urlMessage); }); } $w.onReady(function () { $w("#dynamicDataset").onReady( () => { let title = $w("#dynamicDataset").getCurrentItem().title; $w("#button2").label = title + "'s Website" ; $w("#button1").label = title + "'s Zomato Page" }); });
Also, the content manager is still acting up, it is displaying one text, title, photo on every page. Even though everything is connected to the content manager.
Thanks in advance,
Alex
You cannot “connect” the Content Manager to the HtmlComponent. You need to communicate with the HtmlComponent by passing messages between the HtmlComponent and the page. See the article Corvid: Working with the HTML Element for information on how this is done, and refer to the HtmlComponent API for full details.
See the following example to see how a page and an HtmlComponent communicate with each other:
Multiple Markers in Google Maps
Embed Google Map on your site with multiple location markers , marker clustering, and custom controls using the HTML component.
You stated that “the content manager is still acting up, it is displaying one text, title, photo on every page. Even though everything is connected to the content manager.”
If this is on a dynamic page , then that’s what it’s supposed to do. What are you trying to do? How do you have the page set up? What code do you have?
I meant that it is showing the same text, title, photos on every page. Even though everything is connected to the content manger. And could I have some code that sends a message to the html element. I am a complete novice in coding.
Thanks in advance,
Alex
@alexanderconway
For code on how to pass messages to and from an HtmlComponent, see the article Corvid: Working with the HTML Element . You can also see this code in the Google Maps example .
Since you are a “complete novice in coding”, you should read the following articles to help you start working with Corvid:
This is not a support forum. We are unable to provide full code solutions. If you find that you are having difficulty with code and need assistance, you may want to check out the Wix Marketplace - it’s a place where you can look for Corvid experts for hire.
Could I please have a fix to the text, title, photos not showing different on each dynamic page. Also, the code has a problem in it. It is fine if you do not want to solve this.
Here is a screenshot:

Here is the code in copy/paste form:
export function html1_message(event) {
let urlMessage = $w('#dynamicDataset').getCurrentItem().htmlmap;
$w("#html1").onMessage( (event) => {
$w("#html1").postMessage(urlMessage);
});
}
Thanks in advance,
Alex
Also, I do not want to embed a custom google map. I am looking to embed the location of each restaurant that I have on my website.
@alexanderconway I linked to the example since it demonstrates how to communicate betwen the HtmlComponent and the Page.
In addition to the warning message, your code is incorrect. See the article Corvid: Working with the HTML Element for information on how to perform messaging with the HtmlComponent, and see the example that I linked to.
@yisrael-wix Could you explain why dynamic page is acting up then?