Forms edit content

This commit is contained in:
2020-04-26 18:49:40 +02:00
parent d733468abe
commit 8fb3fb7175
12 changed files with 201 additions and 17 deletions

View File

@@ -0,0 +1,7 @@
document.addEventListener("turbolinks:load", function () {
document.querySelectorAll('pre code').forEach(function (block) {
if (window.hljs) {
hljs.highlightBlock(block);
}
});
});

View File

@@ -13,6 +13,7 @@ require('tinyforms');
require('demo');
require('backend_typed');
require('tabs');
require('highlight');
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)

View File

@@ -40,9 +40,13 @@ window.tinyforms = {
onSubmit: function(e) {
e.preventDefault();
return tinyforms.submitForm(this)
var form = this;
return tinyforms.submitForm(form)
.then((response) => {
this.dispatchEvent(new CustomEvent('tinyforms:submitted', {detail: { submission: response.submission, response: response }}));
if (form.dataset.tinyformsSubmitted && typeof window[form.dataset.tinyformsSubmitted] === 'function') {
window[form.dataset.tinyformsSubmitted](response.submission);
}
})
.catch((response) => {
this.dispatchEvent(new CustomEvent('tinyforms:error', {detail: { submission: response.submission, response: response }}));