Ecommerce Shopify WordPress Discussion

Javascript function defined in view.js not reachable from save.js

I am trying to develop a custom gutenberg block. I have a form in save.js: export default function save() { return ( <div {...useBlockProps.save()}> <form onSubmit={handleSubmit}></form> </div>);} File view.js is defined in block.json ("viewScript": "file:./view.js",) const handleSubmit = async (event) => { event.preventDefault(); const formData = new FormData(event.target); ... }; But when the block renders, it fails. Uncaught ReferenceError: handleSubmit is not defined Its all nice if i use "traditional" javascript (e.g. jQuery, console.log), so enqueueing is not the problem. I am pretty new with "modern" javascript (React, Angular...) and the question is surely pretty dumb, but i am looking for a proper way to coding and not only looking for a functional solution.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.