Skip to content

Commit

Permalink
fix(pat modal): Use jquery-form to be able to upload binary data via …
Browse files Browse the repository at this point in the history
…AJAX.
  • Loading branch information
thet committed Jul 8, 2022
1 parent e5506ee commit 7466336
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/pat/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ export default Base.extend({
var self = this;

// pass action that was clicked when submiting form
var formData = [];
formData.push({ name: $action.attr("name"), value: $action.attr("value") });
var extraData = {};
extraData[$action.attr("name")] = $action.attr("value");

var $form;

Expand Down Expand Up @@ -227,14 +227,10 @@ export default Base.extend({
});
$form.trigger("submit");

// serialize form data
formData = [].concat(formData, $form.serializeArray());

self.loading.show(false);
$.ajax({
$form.ajaxSubmit({
timeout: options.timeout,
type: $form.attr("method"),
data: formData,
data: extraData,
url: url,
error: function (xhr, textStatus, errorStatus) {
self.loading.hide();
Expand Down Expand Up @@ -528,8 +524,9 @@ export default Base.extend({
reloadWindow: function () {
window.parent.location.reload();
},
init: function () {
init: async function () {
import("./modal.scss");
(await import("jquery-form")).default;

var self = this;
self.options.loadLinksWithinModal = $.parseJSON(
Expand Down

0 comments on commit 7466336

Please sign in to comment.