# Reload Panel on change of field (or trigger query fetch again)

**URL:** <https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111>\
**Category:** Questions\
**Tags:** v3\
**Created:** [March 15, 2023, 3:06pm UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111 "2023-03-15T15:06:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuelvontucher](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@samuelvontucher](https://forum.getkirby.com/u/samuelvontucher)\
**Post date:** [March 15, 2023, 3:06pm UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111/1 "2023-03-15T15:06:08Z")

</div>

I’m working on a project were i have a blueprint for a page template called “Event”. The template is used to create pages that represent an event and its related information.

The “event\_location” field allows the user to choose a location from a list of options fetched using a query. The “event\_venue” field allows the user to choose one or more venues for the event based on the location selected in the “event\_location” field. The options for the “event\_venue” field are fetched from a structure field from another page.

```auto
columns:
  main:
    width: 2/3
    sections:
      content:
        type: fields
        fields:
          event_location:
            label: Location
            width: 1/2
            type: select
            options: query
            query:
              fetch: site.find("locations").children.unlisted
              text: "{{ page.location_name }}"
              value: "{{ page.id }}"
          event_venue:
            label: Venue
            width: 1/2
            type: checkboxes
            options: query
            query:
              fetch: site.find(page.event_location).location_venues.toStructure
              text: "{{ structureItem.name }}"
              value: "{{ structureItem.code}}"

```

Everything works fine but when the “event\_location” field changes, the checkboxes of the “event\_venue” field do not update unless you reload the page.

Is there a way to reload the panel when a field changes? Or to trigger the query fetch again to update the “event\_location” variable?

Thank you in advance! Help is much appreciated 😊

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 15, 2023, 5:40pm UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111/2 "2023-03-15T17:40:09Z")

</div>

No, this is not possible. You would have to create a custom solution where field b listens to changes of field a.

---

<div class="post-metadata">

**Author:** ![Oli1](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/oli1/32/14419_2.png) [@Oli1](https://forum.getkirby.com/u/Oli1)\
**Post date:** [March 15, 2023, 10:28pm UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111/3 "2023-03-15T22:28:48Z")

</div>

Not out of the box as Sonja said. But do a simple workaround: for example, place in help text or in a info section (preferred):

```auto
<button onClick="window.location.reload();" class="style-me">Load new entries</button>

```

---

<div class="post-metadata">

**Author:** ![samuelvontucher](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@samuelvontucher](https://forum.getkirby.com/u/samuelvontucher)\
**Post date:** [March 16, 2023, 10:48am UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111/4 "2023-03-16T10:48:36Z")

</div>

Thank you both!

The solution by @Oli1 is a nice workaround but I will have to rethink the whole structure as I can’t rely on the editors to click on the reload button 😅

---

<div class="post-metadata">

**Author:** ![rasteiner](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rasteiner/32/4788_2.png) [@rasteiner](https://forum.getkirby.com/u/rasteiner)\
**Post date:** [March 16, 2023, 2:14pm UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111/5 "2023-03-16T14:14:39Z")

</div>

The problem is that even if you would “reload on change” (actually rather simple to do in a plugin) or a “reload when button was pressed”, the changes wouldn’t have been saved and only exist in your browser.  
Therefore the result of the query would still be the old one, because `page.event_location`, from Kirby’s point of view, would still be the old one.

A workaround would be to automatically save the page when the `event_location` changes, **I don’t know if that is desirable** though. That being said, a minimalist plugin example could look like this:

**site/plugins/venues/index.js**

```js
panel.plugin('samuel/venues', {
  use: [Vue => {
    const orig = Vue.component('k-fields-section');
    Vue.component('k-fields-section', {
      extends: orig,
      methods: {
        async input(values, field, fieldName) {
          if(fieldName === 'event_location') {
            await panel.app.$api.pages.update(panel.app.$view.props.model.id, {
              [fieldName]: values[fieldName],
            });
            panel.$reload();
          } else {
            orig.options.methods.input.call(this, values, field, fieldName);
          }
        }
      },
    })
  }]
});

```

---

<div class="post-metadata">

**Author:** ![samuelvontucher](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@samuelvontucher](https://forum.getkirby.com/u/samuelvontucher)\
**Post date:** [March 17, 2023, 8:37am UTC](https://forum.getkirby.com/t/reload-panel-on-change-of-field-or-trigger-query-fetch-again/28111/6 "2023-03-17T08:37:21Z")

</div>

@rasteiner Thank you for explaining the problem and providing a nice solution. I don’t have that much experience with plugins, so i hadn’t really thought about writing a plugin for my problem.

I don’t see any problems in saving the page automatically.
