Hello
I'm using a JavaScript to refresh a table on submission of form which works well but i'm struggling to get this to work to update a details view on the same page.
Current script for refreshing table:
$(document).on('knack-view-render.view_89', function(event, view, record) {
Knack.views["view_153"].model.fetch();
});
Could you point me in the right direction please?
Hi Tony
Thanks for the input.
The view (which is details view) doesn't refresh with Knack.views["view_263"].model.fetch();
but it does refresh with your suggestion of a refresh all - Knack.router.scene_view.renderViews();
Would be useful to know why the details view doesn't refresh when named individually though.
Thanks
Dan
You should combine the fetch functions and submits into one
$(document).on('knack-form-submit.view_262', function(event, view, record)
Knack.views["view_263"].model.fetch();
Knack.views["view_265"].model.fetch();
});
That should work combining them like above. For future reference, the code below is refresh everything code if you ever need it
$(document).on('knack-form-submit.view_262', function(event, view, record)
Knack.router.scene_view.renderViews();
});
Hi Tony
This still doesn't work with the Details view, But it works with the Table view. (All views are within the same page). When i manually refresh the page after submitting, the details view values update. I've added a screenshot inspecting the view and screenshot of my code.
Is there something different needed in the JavaScript for the details view?
My example code used uses:
View_262 = Submit Form
View_263 = Details View
View_265 = Table View
![](upload://lAdoEX96nYTgA7PCniMnVmlYV5z.png)
![](upload://a2shGvCkTqbQ8EgN4XH0viDDNdR.png)
Then that should work. Drop that code into your javascript and that will update the details view every time the form is submitted
(make sure you refresh the browser for the app you are testing each time you make a change (save) (press reload button)
Hi Tony
Sorry I don't quite understand.
to confirm, view_89 is the submit form and view_153 is the details view.
Try listening for the form submit then refresh the details view.
// Change view_89 to the form view you want to listen to if thats not the form
$(document).on('knack-form-submit.view_89', function(event, view, record)
Knack.views["view_153"].model.fetch();
});