Sanchit
Sanchit

Reputation: 541

Disable dragging while selecting time when creating an event

I am using FullCalender to display calendar and enable users to create events in the calendar, with dynamic duration that can be selected from a dropdown.

When a user only CLICKs on the calendar, I get the desired result that is only the desired duration is selected. which is CORRECT.

But the issue is when a user CLICKs and continues to DRAG to select a time range. I don't want the user to be able to select more than specified duration i.e. say 5mins. Only CLICKing selects 5mins and that is perfectly working fine. Only issue is while DRAGing with CLICKing.

I have tried various options available in the FullCalendar docs, but nothing helped.

Any help is appreciated. Thanks in Advance.

Current integration is in the below link to the Fiddle

https://jsfiddle.net/4h28Lt81/

Jquery is as below:

$('#calendar').fullCalendar({
  header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay'
  },
  defaultView: 'agendaDay',
  slotDuration: '00:05:00',
  slotEventOverlap: false,
  defaultDate: '2016-06-12',
  selectable: true,
  selectHelper: true,
  select: function(start, end) {
    var title = prompt('Event Title:');
    var eventData;
    if (title) {
      eventData = {
        title: title,
        start: start,
        end: end
      };
      $('#calendar').fullCalendar('renderEvent', eventData, true);
    }
    $('#calendar').fullCalendar('unselect');
  },
  editable: true,
  eventLimit: true, // allow "more" link when too many events            
  loading: function(bool) {
    $('#loading').toggle(bool);
  },
  eventRender: function(event, el) {
    // render the timezone offset below the event title
    if (event.start.hasZone()) {
      el.find('.fc-title').after(
        $('<div class="tzo"/>').text(event.start.format('Z'))
      );
    }
  },
  eventClick: function(calEvent, jsEvent, view) {}
});

Upvotes: 0

Views: 612

Answers (1)

Mike
Mike

Reputation: 637

I feel like being able to click and drag how much time you desire for an event is not an issue. That is unless I am missing something in your question. Is it assumed the user only needs to block off 5 minute segments?

If you really want to prevent it from dragging, you can disable it through jQueryUI

myObject.draggable( 'disable' )

Hope this helps!

Upvotes: 1

Related Questions