angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 729 forks source link

Select method does not work with single click in UI-Calendar. #500

Open sharankasandula opened 7 years ago

sharankasandula commented 7 years ago

So I have spent quite a lot of time getting this thing to work.

The ui-calendar repo does not have "select" mothod. i.e, to make a selection to create an event, according to the Full calendar documentation - select (method)

As of now the selection functionality works, except that the event is not created with a single click. Its created only when the user clicks and drags. Did anyone else have this problem as well? I don't have dayClick() function in case you are wondering.

Here's my select() function.

function select (start,end,jsEvent,view){ startTime = start; $scope.endTime = end; $scope.events.push({ start: $scope.startTime, end: $scope.endTime, className: ['Booking'], overlap: false, allDay : false, 'timeDifference' : timeDiff, 'eventPrice' : eventPrice }); }

Also, the selectMinDistance doesn't seem to work. Can someone help me with this? Thanks

Elemy commented 6 years ago

I have the same problem...Have you solved the problem yet?

Elemy commented 6 years ago

thanks a lot! I got a solution yet~

sharankasandula commented 6 years ago

Can you share the solution here in this thread so that it helps others as well. Also, I am curious as to how I you did it.

sh4mz commented 6 years ago

you need to create function for select before init the calendar config. Example :

$scope.select = function (start, end, allDay){
        console.log('Select ' + start, end);
    }

/* config object */
    $scope.uiConfig = {
      calendar:{
          header: {
                left: '',
                center: '',
                right: ''
            },
        eventClick: $scope.alertOnEventClick,
            eventDrop: $scope.alertOnDrop,
            eventResize: $scope.alertOnResize,
            eventRender: $scope.eventRender,
            selectable: true,
            selectHelper: true,
            select: $scope.select,
        firstDay:0,
        defaultView: 'agendaWeek',
        columnFormat: 'dddd',
        editable: false,
        allDaySlot:false,
        events: []
      }
    };