I created two views: parent and child. The parent view creates the child view during setup. The child view has a few dropdown buttons with dynamic options.
When the parent makes changes, it sets the child to display different options in the dropdown menus. Everything works except the UI. The variables are set correctly and the API calls are right, but the dropdown menus are not updated until the page has been refreshed.
For example, one of the dropdown menus is "Time Period", which has "Day", "Week", and "Month" options in a certain mode. When the mode changes, the options for "Time Period" are only "Day" and "Week", so "Month" needs to be removed from the menu. If I remove and recreate the view, it works fine. If I refresh the page, it works fine. I can't figure out how to update the view because view.reRender() doesn't work.
Any help would be greatly appreciated.
This is how the dropdown button is defined:
This is how the view is defined:
This how the view is created:
Finally, this is how I'm trying to change the buttons:
When the parent makes changes, it sets the child to display different options in the dropdown menus. Everything works except the UI. The variables are set correctly and the API calls are right, but the dropdown menus are not updated until the page has been refreshed.
For example, one of the dropdown menus is "Time Period", which has "Day", "Week", and "Month" options in a certain mode. When the mode changes, the options for "Time Period" are only "Day" and "Week", so "Month" needs to be removed from the menu. If I remove and recreate the view, it works fine. If I refresh the page, it works fine. I can't figure out how to update the view because view.reRender() doesn't work.
Any help would be greatly appreciated.
This is how the dropdown button is defined:
Code:
<div class="btn-group pull-right calendar-buttons"> <button type="button" class="btn btn-text dropdown-toggle" data-menu-button="calendar" data-toggle="dropdown">{{{calendarNameSelected}}}</button> <ul class="dropdown-menu pull-right"> {{#each calendars}} <li> <a role="button" tabindex="0" data-action="calendar" data-calendar-id="{{this.id}}"> <span class="fas fa-check filter-check-icon pull-right{{#ifNotEqual ../calendarIdSelected this.id}} hidden{{/ifNotEqual}}"></span> {{name}} </a> </li> {{/each}} </ul> </div>
Code:
setup() { ... this.calendars = this.options.calendars this.calendarIdSelected = this.options.calendarIdSelected } data() { ... return { ... calendars: this.options.calendars, calendarIdSelected: this.calendarIdSelected, calendarNameSelected: this.getCalendarNameById(this.calendarIdSelected), } }
Code:
this.createView('buttons', 'calendar-pro:views/buttons', { ... calendars: this.calendars, calendarIdSelected: this.calendarIdSelected, calendarEvents: this.calendarEvents, calendarIdDefault: this.calendarIdDefault, selector: '.button-container', }, view => { console.log(view) })
Code:
this.getViewByName("buttons").calendars = newCalendars this.getViewByName("buttons").reRender()
Comment