aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/app/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/app/javascript')
-rw-r--r--activestorage/app/javascript/activestorage/blob_record.js7
-rw-r--r--activestorage/app/javascript/activestorage/ujs.js4
2 files changed, 8 insertions, 3 deletions
diff --git a/activestorage/app/javascript/activestorage/blob_record.js b/activestorage/app/javascript/activestorage/blob_record.js
index ff847892b2..7fbe315f76 100644
--- a/activestorage/app/javascript/activestorage/blob_record.js
+++ b/activestorage/app/javascript/activestorage/blob_record.js
@@ -17,7 +17,12 @@ export class BlobRecord {
this.xhr.setRequestHeader("Content-Type", "application/json")
this.xhr.setRequestHeader("Accept", "application/json")
this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")
- this.xhr.setRequestHeader("X-CSRF-Token", getMetaValue("csrf-token"))
+
+ const csrfToken = getMetaValue("csrf-token")
+ if (csrfToken != undefined) {
+ this.xhr.setRequestHeader("X-CSRF-Token", csrfToken)
+ }
+
this.xhr.addEventListener("load", event => this.requestDidLoad(event))
this.xhr.addEventListener("error", event => this.requestDidError(event))
}
diff --git a/activestorage/app/javascript/activestorage/ujs.js b/activestorage/app/javascript/activestorage/ujs.js
index f5353389ef..98fcba60fa 100644
--- a/activestorage/app/javascript/activestorage/ujs.js
+++ b/activestorage/app/javascript/activestorage/ujs.js
@@ -16,7 +16,7 @@ export function start() {
function didClick(event) {
const { target } = event
- if (target.tagName == "INPUT" && target.type == "submit" && target.form) {
+ if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) {
submitButtonsByForm.set(target.form, target)
}
}
@@ -58,7 +58,7 @@ function handleFormSubmissionEvent(event) {
}
function submitForm(form) {
- let button = submitButtonsByForm.get(form) || findElement(form, "input[type=submit]")
+ let button = submitButtonsByForm.get(form) || findElement(form, "input[type=submit], button[type=submit]")
if (button) {
const { disabled } = button