Forms edit content
This commit is contained in:
7
app/javascript/highlight.js
Normal file
7
app/javascript/highlight.js
Normal file
@@ -0,0 +1,7 @@
|
||||
document.addEventListener("turbolinks:load", function () {
|
||||
document.querySelectorAll('pre code').forEach(function (block) {
|
||||
if (window.hljs) {
|
||||
hljs.highlightBlock(block);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -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' %>)
|
||||
|
||||
@@ -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 }}));
|
||||
|
||||
Reference in New Issue
Block a user