---
title: "Javascript Event calendar External Date Picker Navigation Example | Mobiscroll"
component: "Event calendar"
framework: "JavaScript"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/javascript/eventcalendar/navigate-from-external-date-picker"
---

# External Date Picker Navigation - JavaScript Event calendar demo

Use a Javascript event calendar with an external date picker in two-pane layout — date selection navigates the calendar and keeps both in sync. Plain JS api for usage everywhere.

- [Live demo](https://demo.mobiscroll.com/javascript/eventcalendar/navigate-from-external-date-picker)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-javascript/tree/main/src/demos/eventcalendar/calendar-view/navigate-from-external-date-picker)
- This demo in other frameworks: [jQuery](https://demo.mobiscroll.com/jquery/eventcalendar/navigate-from-external-date-picker.md), [Angular](https://demo.mobiscroll.com/angular/eventcalendar/navigate-from-external-date-picker.md), [React](https://demo.mobiscroll.com/react/eventcalendar/navigate-from-external-date-picker.md), [Vue](https://demo.mobiscroll.com/vue/eventcalendar/navigate-from-external-date-picker.md)

## Description

This example demonstrates how can the Eventcalendar navigated externally. Here we have a two-pane layout with a Datepicker on the left and a Calendar on the right. Changing date on the Datepicker will trigger the date change on the Calendar.

The Datepicker calls the [`navigate`](https://mobiscroll.com/docs/javascript/eventcalendar/api#method-navigate) method of the Calendar in its [`onChange`](https://mobiscroll.com/docs/javascript/datepicker/api#event-onChange) event, while the Calendar sets the datepicker value with the `setVal` method from its [`onSelectedDateChange`](https://mobiscroll.com/docs/javascript/eventcalendar/api#event-onSelectedDateChange) event.

## What this demo shows

- This demo shows external navigation between a date picker and a month view event calendar in a two-pane desktop layout.
- **Layout** The date picker is displayed in a separate pane on the left, while the event calendar month view fills the right side.
- **External navigation** Selecting a date in the date picker updates the visible date on the event calendar.
- **Event labels** Days with events display labels directly inside the month cells. Labels use different styles and colors to distinguish all-day events, multi-day, and timed events.
- **Overflow handling** The number of visible event labels depends on the available vertical space in the day cell. Additional events are moved into a popover and indicated by an `X more` label, where `X` represents the number of hidden events. Clicking it opens a popover that lists the remaining events for that day.
- **Label interaction** Hovering over or clicking an event label selects it and highlights the selected label.
- **Day cell states** Hovering a day cell highlights the day number with a gray background, while clicking the empty part of the cell selects the day and highlights the day number with a blue background.
- **Month navigation** The month can be changed by clicking and dragging the calendar left or right.
- **Calendar header** The top-left side shows the current month and year, while the top-right side includes blue previous and next navigation arrows with a `Today` button between them.
- **Date picker header** The date picker header shows the current month and year with previous and next navigation arrows.

## Best for

- **External calendar controls** Apps where users need to navigate the event calendar from a secondary navigation surface.
- **Desktop scheduling layouts** Interfaces that use a two-pane layout to keep date navigation and event overview visible at the same time.
- **Selection-driven workflows** Scheduling and planning experiences where users need clear hover, selection, and active-event states while browsing the calendar.
- **Custom navigation patterns** Products that need to keep multiple calendar-related components in sync when the visible date changes.

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-themeVariant) - option
- [`display`](https://mobiscroll.com/docs/javascript/datepicker/api#opt-display) - option
- [`onChange`](https://mobiscroll.com/docs/javascript/datepicker/api#event-onChange) - event
- [`navigate`](https://mobiscroll.com/docs/javascript/eventcalendar/api#method-navigate) - method
- [`onSelectedDateChange`](https://mobiscroll.com/docs/javascript/eventcalendar/api#event-onSelectedDateChange) - event
- [`setEvents`](https://mobiscroll.com/docs/javascript/eventcalendar/api#method-setEvents) - method

## Code

### JS

```js
mobiscroll.setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

var monthInst = mobiscroll.datepicker('#demo-month', {
  display: 'inline',
  onChange: function (args) {
    dayInst.navigate(args.value);
  },
});

var dayInst = mobiscroll.eventcalendar('#demo-day', {
  onSelectedDateChange: function (args) {
    monthInst.setVal(args.date);
  },
});

mobiscroll.getJson(
  'https://trial.mobiscroll.com/events/?vers=5',
  function (events) {
    dayInst.setEvents(events);
  },
  'jsonp',
);
```

### HTML

```html
  <div class="mds-external-nav-calendar mbsc-flex">
      <div class="mds-external-nav-dp">
        <div id="demo-month"></div>
      </div>
      <div class="mds-external-nav-ec mbsc-flex-1-1">
        <div id="demo-day"></div>
      </div>
  </div>
```

### CSS

```css
  .mds-external-nav-calendar {
    height: 100%;
  }

  .mds-external-nav-dp .mbsc-datepicker-inline {
    height: auto;
  }

  .mds-external-nav-ec {
    border-left: 1px solid #ccc;
  }

  @media screen and (max-width: 700px) {
    .mds-external-nav-calendar {
      display: block;
    }
  }
```

## Implementation notes

- Render an inline `Datepicker` (`display="inline"`) in a left pane and an `Eventcalendar` in a right pane side by side.
- Keep both components in sync through a shared `selectedDate` state variable: in `Datepicker` `onChange`, update `selectedDate` from `args.value`; in `Eventcalendar` `onSelectedDateChange` (Vue: `@selected-date-change`), update `selectedDate` from `args.date`. Pass `selectedDate` to both components so navigating either one updates the other.
- Angular: bind both components to the same value using `ngModel` on the `Datepicker` and `[selectedDate]` on the `Eventcalendar` - no explicit event handlers are needed since the shared binding keeps them in sync automatically.
- JS/jQuery: in `Datepicker` `onChange`, call `calendarInst.navigate(args.value)` to move the calendar; in `Eventcalendar` `onSelectedDateChange`, call `datepickerInst.setVal(args.date)` to update the datepicker.
- Load events from a remote endpoint using `getJson` and assign them to `data`; for the imperative API, call `inst.setEvents(events)` in the callback.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-javascript.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config javascript
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config javascript --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/javascript/getting-started/installation

## Related demos

- Previous: [Switch Day, Week and Month Views](https://demo.mobiscroll.com/javascript/eventcalendar/switching-day-week-month-view.md) - Switch a Javascript event calendar between day, week, and month views using a header segmented control — each view paired with a matching agenda list.
