$w.onReady does not mean it is ready

I just recently started learning about WIX and figuring how it all works. I had really high hopes for WIX but was dashed when I realised there are so many things happening probably related to async calls which causes time dependent results. i.e. the results you get is dependent on how long you wait. That makes for very unrealiable results.

For example, if in the $w.onReady, there are already numerous post where you have to introduce a timeout wait otherwise things like onkeypress etc will be one character late…what the hell ? Cant WIX fix things like this. $w.onReady should be all ready !!

Then worse, if you have dynamic page connected say to a simple collection called “SimpleCollection” which has only two columns “FirstName”, “LastName”. Then you connect the dynamic page to SimpleCollection. If you do a console.log of the FirstName and LastName field in the $w.onReady area, you get things like “Helvetica fonts are the best…” which shows that WIX has not yet loaded the fields with data from the collection. But if you wait 1000 ms using Timeout, then FirstName and LastName returns correctly which is data from the collection.

What the hell ? Time dependent results ? Cant WIX just fix these issue. $w.onready has to mean ready !!

I am so disappointed.

Element event listeners should be ready inside $w.onReady(), do you have any proof that it is not working? Site url?

For datasets, make sure you wrapped the related code inside $w(“#dataset1”).onReady().

You don’t understand the platform much so that’s why something it is not working. Read the docs in depth should helps.

Hi,
Regarding onKeyPress , that’s not a bug but a feature, this is how keypress event works not only on Velo but even if you use the convectional Web API (it fires before the value changes). So either set some timeout or use onInput (no timeout needed, and it’ll also detect mouse copy-paste or speech dictation unlike onKeyPress).

Regarding dataset . you need to put it inside dataset.onReady:

$w.onReady(() => {
 $w('#dataset1').onReady(() => {
   //your code
 })
})

Hi JD and Certified Code.
Thank you so much. Researched like crazy but somehow did not find the dataset.onready command which makes sense now. Thanks greatly. Confidence in WIX and Velo is back now !!!
@Certified Code. that onkeypress event thing not working properly in a $w. onready function unless a timeout is introduced was brought up a few times in this forum. Only way around is to wait like 1000ms or so after $w.onready, Not just keypress, I think…many event listeners dont work properly unless after waiting a bit. Suffice to say $w.onready is not totally ready.

actually J.D. provided a very good reply to the keypress and related issue. J.D. obviously knows his stuff !!