Skip to content

Commit 38c8605

Browse files
Prevent button clicks from clearing ufTable slug
1 parent 6464e04 commit 38c8605

5 files changed

Lines changed: 50 additions & 18 deletions

File tree

app/sprinkles/account/assets/userfrosting/js/pages/register.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
*/
99
$(document).ready(function() {
1010
// TOS modal
11-
$(this).find('.js-show-tos').click(function() {
11+
$(this).find('.js-show-tos').click(function(e) {
12+
e.preventDefault();
13+
1214
$("body").ufModal({
1315
sourceUrl: site.uri.public + "/modals/account/tos",
1416
msgTarget: $("#alerts-page")

app/sprinkles/admin/assets/userfrosting/js/pages/dashboard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
*/
77

88
$(document).ready(function() {
9-
$('.js-clear-cache').click(function() {
9+
$('.js-clear-cache').click(function(e) {
10+
e.preventDefault();
11+
1012
$("body").ufModal({
1113
sourceUrl: site.uri.public + "/modals/dashboard/clear-cache",
1214
ajaxParams: {

app/sprinkles/admin/assets/userfrosting/js/widgets/groups.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function bindGroupButtons(el) {
6363
* Buttons that launch a modal dialog
6464
*/
6565
// Edit group details button
66-
el.find('.js-group-edit').click(function() {
66+
el.find('.js-group-edit').click(function(e) {
67+
e.preventDefault();
68+
6769
$("body").ufModal({
6870
sourceUrl: site.uri.public + "/modals/groups/edit",
6971
ajaxParams: {
@@ -76,7 +78,9 @@ function bindGroupButtons(el) {
7678
});
7779

7880
// Delete group button
79-
el.find('.js-group-delete').click(function() {
81+
el.find('.js-group-delete').click(function(e) {
82+
e.preventDefault();
83+
8084
$("body").ufModal({
8185
sourceUrl: site.uri.public + "/modals/groups/confirm-delete",
8286
ajaxParams: {
@@ -85,7 +89,7 @@ function bindGroupButtons(el) {
8589
msgTarget: $("#alerts-page")
8690
});
8791

88-
$("body").on('renderSuccess.ufModal', function (data) {
92+
$("body").on('renderSuccess.ufModal', function () {
8993
var modal = $(this).ufModal('getModal');
9094
var form = modal.find('.js-form');
9195

@@ -100,7 +104,9 @@ function bindGroupButtons(el) {
100104

101105
function bindGroupCreationButton(el) {
102106
// Link create button
103-
el.find('.js-group-create').click(function() {
107+
el.find('.js-group-create').click(function(e) {
108+
e.preventDefault();
109+
104110
$("body").ufModal({
105111
sourceUrl: site.uri.public + "/modals/groups/create",
106112
msgTarget: $("#alerts-page")

app/sprinkles/admin/assets/userfrosting/js/widgets/roles.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ function bindRoleButtons(el) {
5151
*/
5252

5353
// Manage permissions button
54-
el.find('.js-role-permissions').click(function() {
54+
el.find('.js-role-permissions').click(function(e) {
55+
e.preventDefault();
56+
5557
var slug = $(this).data('slug');
5658
$("body").ufModal({
5759
sourceUrl: site.uri.public + "/modals/roles/permissions",
@@ -100,7 +102,9 @@ function bindRoleButtons(el) {
100102
* Buttons that launch a modal dialog
101103
*/
102104
// Edit role details button
103-
el.find('.js-role-edit').click(function() {
105+
el.find('.js-role-edit').click(function(e) {
106+
e.preventDefault();
107+
104108
$("body").ufModal({
105109
sourceUrl: site.uri.public + "/modals/roles/edit",
106110
ajaxParams: {
@@ -113,7 +117,9 @@ function bindRoleButtons(el) {
113117
});
114118

115119
// Delete role button
116-
el.find('.js-role-delete').click(function() {
120+
el.find('.js-role-delete').click(function(e) {
121+
e.preventDefault();
122+
117123
$("body").ufModal({
118124
sourceUrl: site.uri.public + "/modals/roles/confirm-delete",
119125
ajaxParams: {
@@ -137,7 +143,9 @@ function bindRoleButtons(el) {
137143

138144
function bindRoleCreationButton(el) {
139145
// Link create button
140-
el.find('.js-role-create').click(function() {
146+
el.find('.js-role-create').click(function(e) {
147+
e.preventDefault();
148+
141149
$("body").ufModal({
142150
sourceUrl: site.uri.public + "/modals/roles/create",
143151
msgTarget: $("#alerts-page")

app/sprinkles/admin/assets/userfrosting/js/widgets/users.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ function updateUser(userName, fieldName, fieldValue) {
132132
* Buttons that launch a modal dialog
133133
*/
134134
// Edit general user details button
135-
el.find('.js-user-edit').click(function() {
135+
el.find('.js-user-edit').click(function(e) {
136+
e.preventDefault();
137+
136138
$("body").ufModal({
137139
sourceUrl: site.uri.public + "/modals/users/edit",
138140
ajaxParams: {
@@ -145,7 +147,9 @@ function updateUser(userName, fieldName, fieldValue) {
145147
});
146148

147149
// Manage user roles button
148-
el.find('.js-user-roles').click(function() {
150+
el.find('.js-user-roles').click(function(e) {
151+
e.preventDefault();
152+
149153
var userName = $(this).data('user_name');
150154
$("body").ufModal({
151155
sourceUrl: site.uri.public + "/modals/users/roles",
@@ -191,7 +195,9 @@ function updateUser(userName, fieldName, fieldValue) {
191195
});
192196

193197
// Change user password button
194-
el.find('.js-user-password').click(function() {
198+
el.find('.js-user-password').click(function(e) {
199+
e.preventDefault();
200+
195201
var userName = $(this).data('user_name');
196202
$("body").ufModal({
197203
sourceUrl: site.uri.public + "/modals/users/password",
@@ -201,7 +207,7 @@ function updateUser(userName, fieldName, fieldValue) {
201207
msgTarget: $("#alerts-page")
202208
});
203209

204-
$("body").on('renderSuccess.ufModal', function (data) {
210+
$("body").on('renderSuccess.ufModal', function () {
205211
var modal = $(this).ufModal('getModal');
206212
var form = modal.find('.js-form');
207213

@@ -216,15 +222,19 @@ function updateUser(userName, fieldName, fieldValue) {
216222
toggleChangePasswordMode(modal, userName, 'link');
217223

218224
// On submission, submit either the PUT request, or POST for a password reset, depending on the toggle state
219-
modal.find("input[name='change_password_mode']").click(function() {
225+
modal.find("input[name='change_password_mode']").click(function(e) {
226+
e.preventDefault();
227+
220228
var changePasswordMode = $(this).val();
221229
toggleChangePasswordMode(modal, userName, changePasswordMode);
222230
});
223231
});
224232
});
225233

226234
// Delete user button
227-
el.find('.js-user-delete').click(function() {
235+
el.find('.js-user-delete').click(function(e) {
236+
e.preventDefault();
237+
228238
$("body").ufModal({
229239
sourceUrl: site.uri.public + "/modals/users/confirm-delete",
230240
ajaxParams: {
@@ -248,7 +258,9 @@ function updateUser(userName, fieldName, fieldValue) {
248258
/**
249259
* Direct action buttons
250260
*/
251-
el.find('.js-user-activate').click(function() {
261+
el.find('.js-user-activate').click(function(e) {
262+
e.preventDefault();
263+
252264
var btn = $(this);
253265
updateUser(btn.data('user_name'), 'flag_verified', '1');
254266
});
@@ -266,7 +278,9 @@ function updateUser(userName, fieldName, fieldValue) {
266278

267279
function bindUserCreationButton(el) {
268280
// Link create button
269-
el.find('.js-user-create').click(function() {
281+
el.find('.js-user-create').click(function(e) {
282+
e.preventDefault();
283+
270284
$("body").ufModal({
271285
sourceUrl: site.uri.public + "/modals/users/create",
272286
msgTarget: $("#alerts-page")

0 commit comments

Comments
 (0)