How to refresh a view based on the click of an action button

Does anyone know how to trigger a refresh of a view based on the clicking of an action button? @CarlHolmes’s awesome video shows how to do it based on a form submission, but this is based on an action button click. I know you can do it by redirecting to the same page, but since this is a child page that’s not an option. Thank you!!

1 Like

Hello Cary,

It’s simple just add a menu.
1.
image
2. Add


3.
add below lines

Just change view_11 to view that you need to refresh.

Thanks,
Sunny Singla
ssingla1985@gmail.com

Thanks Sunny…that’s amazingly cool! I think I have 2 issues…1 is that I want the page refresh to occur after clicking an Action Link and not a menu button. That said, I went ahead and set up the “Outcome
What happens after the action is complete?” to go to a url, and added your code as the url and I think it’s working. However, I think now my problem is the fact that the Action button is triggering a scenario in Make (Integromat), and the scenario hasn’t finished yet prior to the page refresh So, my question now is this…is there a way to add a delay to the page refresh with your code? Sorry to be a pain and no prob if you don’t have time to reply. Many thanks, b/c I’ll definitely use the code you sent over on another need.

Hello Gary,

Currently, there is no way in knack that can track whether action is completed in Integromat or not (at least I don’t know) . But yes we can add a delay function after the user clicks an action link. Like below. … with 2 sec delay you can change as per your requirements

$(“#view_xx .kn-detail-body”).live(“click”,function(){

setTimeout(function(){

Knack.views[“view_yy”].model.fetch()

},2000);

});

Regards,
Sunny Singla

2 Likes

That’s awesome! Should I add that code in the action field’s outcome, “redirect to another website URL“ or does it go in the JavaScript or CSS area?

javascript

I’ll give it a shot…THANK YOU!!

Sunny, thank you again! I tried the code above but I’m sure I’m doing something wrong. Here’s what I’m seeing…any thoughts? Loom | Free Screen & Video Recording Software | Loom

Hello Gary,

Look like it works for the table only. when we fetch the detail view it will not update the detail view. We need to work a little extra. Like we call some function.

for this just create an action link in detail view and do nothing in this action link it works. and check the count in object as well.

Regards,
Sunny Singla

Try below page

https://roberts.knack.com/farmers#issues/view-issue-details/6193af38ee4f2a001e27acd6/

click on update first and update some values . then click on action link

Thanks Sunny! The action link with no outcome worked for me :+1::+1:

1 Like

Hi Guys can I jump in on this ? I have a similar issue.
I have a modal popup which is a combined entry screen with a details view above it. Basically the entry screen stores url links to one drive images.
When I press submit it saves them then I have to exit back to the parent page and go back to the screen again to see the results which appear in the details screen.
Could roberts method be used such that it will not only update the entry screen and refresh but also refresh the details screen at the same time ?
So if I add one of the embedded codes into the screen or alter one when I do a submit (or a reload if need be) then it would be great to see the changes implemented .
The screen layout is attached might make more sense.


Cheers

Try to add an action link on the detail page as said.

Don’t update anything in that action link.

And trigger click functionality(using javascript) after uploading images

1 Like

Thanks Sunny but I am an absolute novice in javascript (and CSS) for that matter. Knack has trigger function but all that doe sis created a new butotn that has to be clicked on so I am assuming that not what we are looking for.
So I assume there is a simple 3 or 4 lines of javascript that can be added that would do what your suggesting ?

Hello Ray,

Only javascript doesn’t work to refresh the detail view without loading the whole page.

You can add an action link on the detail page. and don’t update anything with this button.

But trigger click function after update or form submit rule.

try below code

$(document).on(‘knack-form-submit.view_116’, function (event, view, data) { // Login Page to Redirect change view_116 to your view id where you upload images or update
$(“#view_117 .kn-action-link”).trigger(“click”); // change this view_117 to your detail view
});

Check working demo
https://roberts.knack.com/farmers#images/edit-imagetest/632c9870ea9d78002188d6ce/

Regards,
Sunny Singla
ssingla1985@gmail.com

Thanks Sunny
Have added the javascript and indeed it does appear to invoke the action in the details section, in fact I was “daring and added a second details section to be triggered”.
Got it working - thank you for all your time.
Much appreciated. I am sure my research team will see this of great benefit

1 Like

This is a great topic!! I have a similar issue. When building an inventory order, I would like the table below the form to be refreshed upon form submission. You can see the products added to the table after each form submission, but it doesn’t pull in (“Refresh”) the Connected data, which is the product image, billing code and stock status, these are the fields in a different Object. If I manually refresh, they will show up, but they dont as you build an inventory order normally. Any ideas? The form above is set to automatically reload the form upon each submission.

hello JD,

You can refresh the table easily. by applying the code after the form submits in javascript.

Knack.views.view_xyz.model.fetch();

Thanks,
Sunny Singla

Sunny, like this? Its not working for me. It adds the product to the table still, but doesnt refresh the table enough to show the connected data.

Hello JD,

You need to call this on the javascript side. Records created/updated or form submit event.

Thanks,
Sunny Singla