javascript - AngularJS and Fullcalendar: eventClick works only first time -
i'm using angular module based on fullcalendar: https://github.com/angular-ui/ui-calendar along dialog module ng-bootstrap. configured calendar show dialog editing event on eventclick action. works fine once. after closing first dialog , clicking again on event new dialog doesn't show. when click on other link on page, desired dialogs shows 1 one they're queued somewhere way.
here's snippet controller:
$scope.showeditvisitdialog = function (event) { var editvisitdialogopts = { backdropclick: false, templateurl: 'views/addeditvisitdialog.html', controller: 'addeditvisitdialogcontroller', resolve: { patientid: function () { return event.patientid; }, visitid: function () { return event.id; } } }; var editvisitdialog = $dialog.dialog(editvisitdialogopts); editvisitdialog.open().then(function (updatedvisit) { //some action }); }; $scope.calendar = { height: 450, editable: true, header: { left: 'month agendaweek ', center: 'title', right: 'today prev,next' }, eventclick: $scope.showeditvisitdialog }; $scope.events = []; $scope.eventsources = [$scope.events]
events fetched rest later in controller.
in html: <div ui-calendar="calendar" config="calendar" ng-model="eventsources"/>
no errors in console, doing wrong?
code on plunker: http://plnkr.co/edit/89sqfsu85zn4uxaufi2y?p=preview
as always, things simpler , more obvious when there's fiddle/plnkr available. need place call showeditvisitdialog
inside $apply function:
... $scope.calendar = { editable: true, eventclick: function(){ $scope.$apply(function(){ $scope.showeditvisitdialog() }); } }; ...
working plnkr.
Comments
Post a Comment