okkur / syna

Highly customizable open source theme for Hugo based static websites
https://syna.okkur.org/demo/
Apache License 2.0
250 stars 134 forks source link

[Documentation Request] Editor Form Button How to? #749

Closed zecbmo closed 4 years ago

zecbmo commented 4 years ago

Documentation Feature Request:

It would be great if you could add documentation on how to add delegates to the forms onSubmit function.

OnSubmit -> DoSomething

Thanks

stp-ip commented 4 years ago

Not really a Syna question. Take a look at javascript event listeners. An event listener can prevent the default function of the button and on submit run a specific function.

Something along the lines of

"document.querySelector(".editor-container").addEventListener("submit", function(e){
    if(!isValid){
        e.preventDefault();
    }
});