16
Views
8
Comments
Solved
Refresh header container with an event inside a web block in a screen
Application Type
Traditional Web

Hi,

I'm a starter and I'm a bit lost with ajax refresh, here's the scenario:
I have a cart in the header with a product counter that it is working when a "add to cart" button is clicked inside de the main content, I can refresh that counter if I refresh the whole page, but I just want to refresh the cart/or the header or something like that, is it possible?

Rank: #127
Solution

Hi Joao,

some things that you need for this to work :

as the change is happening inside a webblock, and you want to refresh something on the screen, your webblock will need an event to allow communication of the change to the screen.  Every time user clicks addToCart button, you need to trigger the event.  Also, you are now forcing a refresh of the whole screen by flowing to the home screen at the end of the AddToCart Action, that should be restored to a simple end node.

Widgets that you want to refresh with AjaxRefresh need to have a name.  So give the webblock holding the cart count a name.


You have already defined an action to refresh the header.  For every instance of the Cards webblock, you will have to set that as the handler action of the changed event.

And inside that action, you are currently not doing anything yet, you will have to add the ajax refresh there.


I can't really test if that is all you need to change, as we don't have your core module, but this should bring you a lot closer to what you are trying to do.

Dorine

Rank: #3109

Many many thanks!

I knew all the logic you described but I was changing the name of the block at the wrong place.... your explanation was perfect and lead me to solve my problem!!

Thanks a lot!

Hi Joao,

Good day!

Yes, please make sure that the header is encapsulated by a container (with a name). Then use the ajax refresh node to rerender the container. Also, please make sure that your button's method is set to Ajax submit 

Hope this helps,

Kind regards,

Chris

Rank: #3109

Thanks for your answer, but I'm still not getting it...

Here's the scenario to check if I'm doing right:
I've a web block inside a Screen
Inside that web block I've a event that triggers after a certain action is called.
That event is handled by the screen and it will call an action that will ajax refresh the header....I've encapsulated the header but it still doesnt show as an option to ajax refresh...

What am I doing wrong?

Rank: #54

Hi João,


In order to AJAX refresh a given widget of the screen, you need to fill in a name for it.

Take a look at the example below. In order to AJAX Refresh the menu, I need to give it a menu, in my case WB_Menu:


Now on your handler of the block's event, my WB_Menu, will appear as an option on the widget to AJAX Refresh:


When you need to display several widgets, you can enclose them in a container, give a name to that container and do a single AJAX refresh on that container using the given name as the example above.


Hope it helps.


Kind Regards,
João


Rank: #3109

Thanks for trying to help me, I don't know what I'm doing wrong


Rank: #2139

Hey Joao, 


Would it be possible to share the oml? It would be much easier to find the cause :)



Rank: #3109

Of course, and many thanks!

joaocoelho.oml

Rank: #127
Solution

Hi Joao,

some things that you need for this to work :

as the change is happening inside a webblock, and you want to refresh something on the screen, your webblock will need an event to allow communication of the change to the screen.  Every time user clicks addToCart button, you need to trigger the event.  Also, you are now forcing a refresh of the whole screen by flowing to the home screen at the end of the AddToCart Action, that should be restored to a simple end node.

Widgets that you want to refresh with AjaxRefresh need to have a name.  So give the webblock holding the cart count a name.


You have already defined an action to refresh the header.  For every instance of the Cards webblock, you will have to set that as the handler action of the changed event.

And inside that action, you are currently not doing anything yet, you will have to add the ajax refresh there.


I can't really test if that is all you need to change, as we don't have your core module, but this should bring you a lot closer to what you are trying to do.

Dorine

Rank: #3109

Many many thanks!

I knew all the logic you described but I was changing the name of the block at the wrong place.... your explanation was perfect and lead me to solve my problem!!

Thanks a lot!