js: fixup issues with @rails/ujs.
Fix a couple regressions caused by the migration from jquery-ujs to
@rails/ujs in 9f4ac4c96:
* Add authenticity tokens to all remote forms. By default, Rails doesn't
doesn't include authenticity tokens in remote forms because it can cause
problems with fragment caching. This was fine with jquery-ujs because it
would insert the authenticity token when the remote form was
submitted, but apparently @rails/ujs doesn't do this. This broke
certain remote forms nested inside of jquery UI dialogs.
* Fix dialogs to trigger remote form submissions through @rails/ujs
instead of through jquery. This fixes a problem where remote forms that
returned a javascript response displayed the response as plaintext
instead of executing the returned javascript.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Utility from "./utility";
|
||||
import Rails from "@rails/ujs";
|
||||
|
||||
let ArtistCommentary = {};
|
||||
|
||||
@@ -34,7 +35,8 @@ ArtistCommentary.initialize_edit_commentary_dialog = function() {
|
||||
width: 700,
|
||||
buttons: {
|
||||
"Submit": function() {
|
||||
$("#add-commentary-dialog #edit-commentary").submit();
|
||||
let form = $("#add-commentary-dialog #edit-commentary").get(0);
|
||||
Rails.fire(form, "submit");
|
||||
$(this).dialog("close");
|
||||
},
|
||||
"Cancel": function() {
|
||||
|
||||
@@ -3,6 +3,7 @@ import Utility from './utility'
|
||||
import Hammer from 'hammerjs'
|
||||
import Cookie from './cookie'
|
||||
import Note from './notes'
|
||||
import Rails from '@rails/ujs'
|
||||
|
||||
let Post = {};
|
||||
|
||||
@@ -556,7 +557,8 @@ Post.initialize_saved_searches = function() {
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Submit": function() {
|
||||
$("#save-search-dialog form").submit();
|
||||
let form = $("#save-search-dialog form").get(0);
|
||||
Rails.fire(form, "submit");
|
||||
$(this).dialog("close");
|
||||
},
|
||||
"Cancel": function() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import CurrentUser from "./current_user";
|
||||
import Rails from '@rails/ujs';
|
||||
|
||||
let Utility = {};
|
||||
|
||||
@@ -54,7 +55,8 @@ Utility.dialog = function(title, html) {
|
||||
},
|
||||
buttons: {
|
||||
"Submit": function() {
|
||||
$dialog.find("form").submit();
|
||||
let form = $dialog.find("form").get(0);
|
||||
Rails.fire(form, "submit");
|
||||
},
|
||||
"Cancel": function() {
|
||||
$dialog.dialog("close");
|
||||
|
||||
Reference in New Issue
Block a user