Help for onReady function

Good morning at all!
I need an help for the onReady function.
My website is " www.313-distribution.com "

I like to activate the functions (mouseOn) on my website,
but I don’t find the right code: I try many solutions, but doesn’t works.

Someone can halp me with am onReady code for activate my mouseOn function?

Thanks!!
Andrea

Hello Andrea,

First of all, here is the code that you need:

$w("#yourItemId").onMouseIn((event) => {
    //write your code here (what will happen after onMouseIn event)
})

or

$w.onReady(function () {
    $w("#yourItemId").onMouseIn((event) => {
        //write your code here (what will happen after onMouseIn event)
    })
})

onReady function is triggering when your page is ready (loaded) so when you write a code inside this function it means your function will be fired after the page loaded.

For your event listener (onMouseIn is an event listener) you can put this code inside onReady. But you don’t have to put every code into onReady.

But you don’t have to put every code into onReady.

But you can if you want to. :wink: (sometimes it is even better to do so) → less global variables.

@russian-dima Yes I meant you can create a function and put the code in the function then call the function in onReady. Actually I meant this :slight_smile: To make the code clear.

Hi! Thank you for your answer!
I try to use your code but maybe I don’t undertand what I have to do
Can you help me with an example, please?
This is one of my code inside my website:

export function tretorn_mouseIn ( event ) {
$w ( ‘#tretorn’ ). onMouseIn (() => { $w ( ‘#tretornimg’ ). show (); })
}
export function tretorn_mouseOut ( event ) {
$w ( ‘#tretorn’ ). onMouseOut (() => { $w ( ‘#tretornimg’ ). hide (); })
}

@andreacattonar
You will have to TRANSFORM your CODE into another CODE-Technique…
Instead of using export-functions for elements on your page, you can do it another way…

AyDontLoss already showed you the first part of code you need, now all you have to do is to convert it a little bit…

$w.onReady(function () {console.log("Page READY!");
              
    $w('#YourElementID').onMouseIn((event)=>  {$w('#YourElementID').show('fade');});
    $w('#YourElementID').onMouseOut((event)=> {$w('#YourElementID').hide('fade');});
 
});

And next time → Please use CODE-Blocks to show your code…like this…

Thank you VeloNinja!! You resolve my problems! Amazing!

Good Morning, I am looking for assistance with this code, it worked as it should in test, but when I published it on the website, the input from the user is not showing up in the repeater. Any idea why it is not functioning correctly? Thanks,

Error message:
Property ‘onAfterSave’ does not exist on type ‘MultistateBox’.

$w ( “#commentswrite” ). onAfterSave ( () => {

@xt61 If you are not talking about the code showed by me, then you better should open a new post with your own issued situation.

I asume that your code …

$w("#commentswrite").onAfterSave(()=>{

…has nothing to do with this post (or you do not show enough of your code).