# receiving "$w(...).on is not a function" error

**URL:** <https://forum.wixstudio.com/t/receiving-w-on-is-not-a-function-error/38052>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [August 4, 2022, 1:07am UTC](https://forum.wixstudio.com/t/receiving-w-on-is-not-a-function-error/38052 "2022-08-04T01:07:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukeatlastech](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lukeatlastech/32/26585_2.png) [@lukeatlastech](https://forum.wixstudio.com/u/lukeatlastech)\
**Post date:** [August 4, 2022, 1:07am UTC](https://forum.wixstudio.com/t/receiving-w-on-is-not-a-function-error/38052/1 "2022-08-04T01:07:10Z")

</div>

In my code I have a popup with a custom element in it for uploading files. However, whenever you open the popup up for the first time it gives a “$w(…).on is not a function” error and none of the other non-custom buttons on the popup work. BUT if you close the popup and open it a second time without refreshing the page or anything, then it works just fine. I have no idea what could cause this other than the site trying to register the event before the element is loaded. If that is the problem then I have no idea how to fix that. What should I do?

> **[Members \_ Health Unite - Google Chrome 2022-08-03 17-25-33.mp4](https://drive.google.com/file/d/1jhmdmr9Rw18NeQwZLFUsfrf0BRCZzony/view?usp=sharing)**
>
> Google Drive file.

let curRow = - 1 ;  
let curData = {};  
let hidden = **true** ;  
let uploaded = **false** ;  
let csvArr ;

$w ( ‘#customElement1’ ). on ( ‘my-event’ , ( event ) =\> {  
console . log ( ‘The event triggered successfully.’ );  
console . log ( event . detail . name )  
let rows = $w ( “#table1” ). rows ;  
csvArr = event . detail . name . split ( “\n” );  
uploaded = **true** ;  
$w ( “#button14” ). enable ();  
**for** ( let j = 1 ; j \< csvArr . length ; j ++) {  
let userArr = csvArr [j]. split ( “,” );  
let email = userArr [1];  
let fullName = userArr [0];  
let phonenumber = userArr [2];  
rows . push ({ name : fullName , Email : email , phoneNum : phonenumber });  
}  
$w ( “#button14” ). enable ();  
$w ( “#button12” ). disable ();  
$w ( “#button13” ). disable ();  
curRow = - 1 ;  
$w ( “#table1” ). rows = rows ;  
$w ( “#input1” ). value = “” ;  
$w ( “#input2” ). value = “” ;  
$w ( “#input3” ). value = “” ;  
$w ( “#input4” ). value = “” ;  
});

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [August 4, 2022, 10:06pm UTC](https://forum.wixstudio.com/t/receiving-w-on-is-not-a-function-error/38052/2 "2022-08-04T22:06:56Z")

</div>

If the customElement1 element exists on your page, this error means you set the $w(‘#customElement1’).on from outside the $w.onReady. So move it to the block of the $w.onReady.

---

<div class="post-metadata">

**Author:** ![lukeatlastech](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/lukeatlastech/32/26585_2.png) [@lukeatlastech](https://forum.wixstudio.com/u/lukeatlastech)\
**Post date:** [August 4, 2022, 10:43pm UTC](https://forum.wixstudio.com/t/receiving-w-on-is-not-a-function-error/38052/3 "2022-08-04T22:43:26Z")

</div>

Thank you! It was driving me crazy
