THe documentation, the examples, the Property window all refer to a Dynamic Dataset Event event Onready. But if you insert code, ready is pasted in, not Onready. And it (ready) is fired.
Something changed?
Hey
There is two events, one is the onReady when the current page is loaded. This has nothing to do with the datasets. Inside this ready function you should put your code and functions outside.
The dataset onReady is when the dataset you drag out on a page is ready for interaction using code. Read more about this onReady here:
Hi Andreas, thanks for your answer. Maybe I did not make myself clear enough. I´ll try again:
- click a dataset icon an active page
- goto its properties (right click/Properties)
- in the Events List, at the bottom there is the OnReady Event
- click it and the Code WIndow opens with a prefab code snippet for that event. It generates:
export function DynamicDataSetName_ready(event) {
5)according to all documentation, this should be called DynamicDataSetName_Onready(event) { - why has it changed?
Hey Giri,
Here’s what’s going on.
The event is actually called the “ready” event. You will almost never use the name of the event.
There are two ways to create an event handler for a given event. When you use a function on the element to bind an event handler you are creating a dynamic event handler. The name of the function always begins with “on”, like “onClick”. When you use the properties panel to bind an event handler you are creating a static event handler. Even though the name of the event is something like “click”, the list of events mirrors the function names used for binding dynamic event handlers, so they all start with the “on”.
Every thing until here should not affect what you write in your code at all. Now for what does affect your code.
When you create a static event handler using the properties panel, a default name is given to your event handler function. That name will be the name of the element, and underscore, and the name of the event. That is just the default name though. You can name this anything you want. The important thing to know is that the name in the properties panel must match the name in the code panel.
Thank you for that, Sam. But now I have another problem. I am still toying around with code to get a Google Maps iframe to load on every individual dynamic page. I thought I needed the HTML.component for that, until I found out yesterday in the Table Index example that the text box has a .html property. “Hurray, salvation is neigh”, I shouted (or at least something close).
So I took that code, changed it around a bit, but it does not work:
1)if I use the _ready event handler, it is fired, but the html field is empty (basically, every other field I tried too)
2) if I change it to _onReady, it is not fired, I don´t get my console debug texts
I read somewhere that there is a way to copy the code with all the colours, but I can´t find it. Could you tell me?
Hey Giri,
I’m not exactly sure what you’re trying to do, but putting the HTML for a Google Map in a text element will definitely not work. The text element only supports a subset of HTML as described in the API Reference .
Depending on what you’re trying to do with the map, you might want to check out the Wix Google Map element .
As far as the colors in the code: these are just syntax highlights. Basically, each type of token (language keywords, function names, string literals, etc.) have their own colors. This usually makes the code easier to read and write, but it does not affect your code at all.
Oh, bummer. Well, I will try that out, thanks again. About the code: I wanted to do a print screen of my code, so I could paste it here. I thought there was some way to do that, keeping all the colours, that´s what I meant.
Oh, I see. If you take a screenshot the colors should be there. But if you actually copy and paste the text of the code the colors will not show up.
What I am trying to achieve is this. I have a table with hotels, restaurants, etc. From the Table app, users go to a Dynamic Page. On that page, I want to show every hotel´s or restaurants individual location on a Google Map.
I am right now checking out the GoogleMaps component, I see it has location properties. But back to the not firing of the event. Here´s the code,
$w.onReady(function () {
//TODO: write your page related code here…
});
export function ddsPropsVIew_onReady(event) {
//Add your code for this event here:
console.log(“In onready”);
let ifrmGoogleMaps = $w(‘#ddsPropsVIew’).getCurrentItem().GoogleMaps;
console.log(“html=” + ifrmGoogleMaps);
$w(‘#GoogleMapsPort’).html = ifrmGoogleMaps;
}
The Dataset´s name is correct (yes, even with the weird spelling of VIew). t is just not fired. And don´t mind the old iframe stuff. I get it now that it won´t work that way, but I first have to get the event fired in the first place. Thanks for any advice you can give me.
I’m sure you’ve checked, but I have to mention it anyhow. Are you sure the name of the event handler in the properties panel matches the name you have here in the code: ddsPropsVIew_onReady .
Do you have other errors that might be stopping the function from running? Maybe try commenting out the rest of the code on your page and check if the console.log is run.
That was it, Sam, I checked everything, BUT that. Cheeks flush with great shame. Also solved the other problem (return of Null): I used the row´s description instead of the field name.
Thanks for your help.
That should be : colums description instead of field name