Problem/Motivation
I have a view that renders entities and I use hook_entity_view_mode_alter()
to alter the view mode depending on different settings. This works fine. However when I refresh the view through JQuery:
$(myViews).trigger('RefreshView');
the view gets refreshed, but the entity is not rendered anymore using the view mode set by hook_entity_view_mode_alter()
but is using the view mode set in views. It seems hook_entity_view_mode_alter()
is not executed on refresh.
Steps to reproduce
- Create a fresh Drupal Install
- Create a new module (
my_module
) with the code hook below:
function my_module_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) { $view_mode = 'full'; }
- Create a new Tag in the Tags vocabulary
- Create a new Article (node) using this Tag
- Update the Taxonomy view to Use Ajax
- Go to the Taxonomy page to list every articles (
/taxonomy/term/1
) - Run the problematic command
jQuery('.view.view-taxonomy-term').trigger('RefreshView');
Proposed resolution
It seems the issue has already beed fixed between 8.5.3 to 8.9.x.
Remaining tasks
Try to reproduce the issuewrite a step-by-stepPatch the issue if needs- Review
Comments
Comment #2
valthebaldComment #3
mdupontI am at DrupalCon Amsterdam and I am looking into this issue.
Comment #4
wengerkHey there ! I'm mentoring - alongside with @mbovan - @mdupont and @hanan_apw at the Drupalcon in Amsterdam 2019.
Comment #5
Phil_bHi there. I´m at DrupalCon in Amsterdam 2019 and i´m helping to solve this issue
Comment #6
hanan alasariHi there. I´m at DrupalCon in Amsterdam 2019 and i´m helping to solve this issue.
So i tried:-
my_custom
) with the code hook below:/taxonomy/term/1
)jQuery('.view.view-taxonomy-term').trigger('RefreshView');
)and seems there is no issue. Its work fine to me.
Comment #7
valthebaldCan someone update the issue summary, following https://www.drupal.org/node/1155816 as an example?
Comment #8
valthebaldAfter the issue summary is updated, status can be set to Closed (works as expected)
Comment #9
wengerkUpdated summary as requested.
Comment #10
wengerkComment #13
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedRemoving Europe2020 tag, since this issue was not worked on at Drupalcon Europe 2020.
Comment #14
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedComment #15
SpokjeAs per #8
because of updated IS: