In my case, It was neither “eventS.js” nor “import wixStores from ‘wix-stores-backend’”
It was ‘TEST SITE’!
You should “Publish” first to make backend event handlers in ‘events.js’
Then, all changes in event handlers code will be reflected in “Test Site” as well.
To reproduce:
0. Install wix blog
- Publish your site using “Publish Button” site comment out any event handler in ‘events.js’ like
// events.js
// export function wixBlog_onPostCreated(event) {
// console.log('new blog posted!',event)
// }
- Use “Create Test Site” to make test site with the event handler uncommented
//events.js
export function wixBlog_onPostCreated(event) {
console.log('new blog posted!',event)
}
-
Open Developer Tools> Site Events>
-
Try add a blog post. You will see nothing in Site Events log. onPostCreated handler was not triggered.
-
Now, “Publish” site. And add a blog post. You will see a log in Site Events. onPostCreated handler triggered!
-
Now change code in events.js
//events.js
export function wixBlog_onPostCreated(event) {
console.log('new blog posted in Test Site',event)
}
- Check Event log. You will see a log ‘new blog posted in Test Site’ now triggered with new code.
I think events.js handlers are registered only when they are published. Once registered in backend, triggered with new code in events.js
I hope this saves you time.