Closed ChristinaTremel closed 2 months ago
@ChrispinP could you provide details on how you've addressed auto refreshing pages in the past?
Sent code to Christina & Diana for review
We are testing the code that Chrispin shared with us and the Street Banners.
These are the values for the pages we need the code applied to:
scene_431
view_1020
scene_364
view_1045
scene_433
view_1134
/*****************************/
/*** Refresh Table Button ***/
/*****************************/
$(document).on("knack-view-render.view_322", function (event, page) {
var button = $(
"<span style='width: 2em'></span>" +
"<button id='refresh-view_322' style='border-radius: .35em' class='kn-button is-primary'>" +
"<i class='fa fa-refresh'></i>" +
"<span style='width: .5em'></span>Refresh Table</button>"
);
button.insertAfter( //places button next to keyword search option
$("#view_322").find("form.table-keyword-search").find("a")[0]
);
$("#refresh-view_322").click(function (e) {
e.preventdefault();
Knack.views["view_322"].model.fetch();
});
});
$(document).on('knack-scene-render.scene_446', function(event, scene) {
$('button[type=submit]').submit();
});
// Reload LPB Application when Design Ready "Yes"
$(document).on("knack-scene-render.scene_1212", function () {
$('#view_3392 .kn-link:contains("Yes")').on("click", function(){
location.reload();
})
});
// Reload OTS Application when Design Ready "Yes"
$(document).on("knack-scene-render.scene_1234", function () {
$('#view_3397 .kn-link:contains("Yes")').on("click", function(){
location.reload();
})
Details
iconAdd | Edit Service Request Job
buttonTK
Increase
1125
, select an existing TKSave Job
$("#refresh-view_322").click(function (e) {
e.preventdefault();
Knack.views["view_322"].model.fetch();
});
});
I mentioned this grooming—if you want to try testing again by running this line in the javacsript console in your browser:
Knack.views["<view_id>"].model.fetch();
You should replace <view_id>
with the view ID of the table you want to refresh. Hopefully that works!
TEST | JUL 25 2023 - Finance and Purchasing System
I am going to look into this!
I have code in test app but this is what I found to work:
var viewsToFetch = ["view_1070", "view_1067", "view_1065", "view_1060", "view_1057"]
// When the form in view 1045 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1045", function (event, view, data) {
viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})
@chiaberry Thank you! I just tested that form in the test app and that code seems to be working. 🙏🏼 I'll sync with Diana early next week to test it out again/implement it in the prod app.
Had to update the code to include Subprojects, but this code worked in test 🎉
var viewsToFetch = ["view_1070", "view_1067", "view_1065", "view_1060", "view_1057", "view_1056]
// When the form in view 1045 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1045", function (event, view, data) {
viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})
Need to identify views in production, but then we're ready to implement!
view_867
view_865
view_870
view_857
view_1062
view_1061
view_1068
var viewsToFetch = ["view_867", "view_865", "view_870", "view_857", "view_1062", "view_1061", "view_1068"]
// When the form in view 1045 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1045", function (event, view, data) {
viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})
Subprojects - view_1161
FDUs - view_1162
TK - view_1163
JV - view_1165
IET - view_1166
Other - view_1167
Subprojects - view_867
FDU - view_865
TK - view_870
JV - view_1062
IET - view_1061
Other - view_1068
Subprojects - view_1183
FDU - view_1191
TK - view_1185
JV - view_1186
IET - view_1187
Other - view_1188
Requester Details - Add Job
var viewsToFetch = ["view_1161", "view_1162", "view_1165", "view_1163", "view_1166", "view_1167"]
// When the form in view 1020 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1020", function (event, view, data) {
viewsToFetch.forEach(view => Knack.views[view].model.fetch())
})
var viewsToFetchUserAdd = ["view_867", "view_865", "view_870", "view_1062", "view_1061", "view_1068"]
// When the form in view 1181 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1181", function (event, view, data) {
viewsToFetchUserAdd.forEach(view => Knack.views[view].model.fetch())
})
var viewsToFetchAdmin = ["view_1183, "view_1191", "view_1185", "view_1186", "view_1187", "view_1188"]
// When the form in view 1182 has been submitted, refetch the views
$(document).on("knack-form-submit.view_1182", function (event, view, data) {
viewsToFetchAdmin.forEach(view => Knack.views[view].model.fetch())
})
Chia helped us fix the code by renaming the viewstofetch for each page we were refreshing. Diana and I tested and this works ✅
Still need to do PR @dianamartin
When submitting new jobs on a Service Request, the job information shows up under all of the Service Request job tables until the page is refreshed. Can we auto refresh the page when a user clicks "Add Job"?