JavaScript Event calendar Event Search Sidebar

Inline search can be easily implemented with the help of a separate agenda instance. This example is relying on a single API endpoint for getting the data onto the primary calendar view and also for getting the filtered data based on the search terms.

Events can be filtered in real time so using an agenda view for the search results is an easy choice. It provides all the necessary styling and advanced features that you might need to customize the experience.

Alternatively, search can be implemented in the header of the event calendar using a similar search box with an agenda listed in a popup instead of rendered inline.

Download and try example

Demo

Loading the live demo

Preview in full screen

Filter events in real time from a sidebar search box and show results in an agenda list that jumps the event calendar to the chosen date.

Code

mobiscroll.setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

var timer;
var searchResults = document.getElementById('demo-search-results');

var list = mobiscroll.eventcalendar('#demo-search-results', {
  view: {
    agenda: { type: 'year', size: 5 },
  },
  showControls: false,
  onEventClick: function (args) {
    calendar.navigateToEvent(args.event);
    calendar.setSelectedEvents([args.event]);
  },
});

var calendar = mobiscroll.eventcalendar('#demo-search-events', {
  clickToCreate: false,
  dragToCreate: false,
  dragToMove: false,
  dragToResize: false,
  selectMultipleEvents: true,
  view: {
    calendar: { labels: true },
  },
  onPageLoading: function (args) {
    var start = mobiscroll.formatDate('YYYY-MM-DD', args.viewStart);
    var end = mobiscroll.formatDate('YYYY-MM-DD', args.viewEnd);

    mobiscroll.getJson(
      'https://trial.mobiscroll.com/searchevents/?start=' + start + '&end=' + end,
      function (data) {
        calendar.setEvents(data);
      },
      'jsonp',
    );
  },
});

searchResults.style.visibility = 'hidden';

document.getElementById('demo-search-input').addEventListener('input', function (ev) {
  var searchText = ev.target.value;
  clearTimeout(timer);
  timer = setTimeout(function () {
    if (searchText.length > 0) {
      mobiscroll.getJson(
        'https://trial.mobiscroll.com/searchevents/?text=' + searchText,
        function (data) {
          list.setEvents(data);
          searchResults.style.visibility = 'visible';
        },
        'jsonp',
      );
    } else {
      searchResults.style.visibility = 'hidden';
    }
  }, 200);
});
  

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.