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

Changed ui-calendar config doesn't pass functions #297

Open ChristianSteu opened 9 years ago

ChristianSteu commented 9 years ago

I recently updated to the new version of of ui-calendar and I can't proberly pass the config object any more.

I changed my old code from

<div ui-calendar="configObject" ...

to

<div ui-calendar="{{configObject}}" ...

according to the changes made to the demo on github. (My configObject is attached to a controller and is accessed via controllarAs Syntax, but I think that shouldn't be relevant here.)

The problem is that the new way of passing the config object doesn't forward functions I assigned to it:

var configObject = {
  eventDataTransform: function(eventData) {
    // do some fancy stuff with my event
  }
}

The calendarSettings object created in getOptions() via

var calendarSettings = attrs.uiCalendar ? scope.$eval(attrs.uiCalendar) : {}

doesn't have a property eventDataTransform at all (other properties are working fine).

Changing the calendarSettings back to access $parent (and dropping the {{}} from the directive) makes it working fine again.

MCSCC commented 9 years ago

@ChristianSteu Thank you soo much!!! Way too long I was trying to figure this out.

MaxYari commented 9 years ago

can you specify what changes exactly need to be made? I just got this calendar, and have no idea how it was working before this functions breaking change

ChristianSteu commented 9 years ago

I changed the line above (in the current version it is line number 229) from

var calendarSettings = attrs.uiCalendar ? scope.$eval(attrs.uiCalendar) : {},

back to

var calendarSettings = attrs.uiCalendar ? scope.$parent.$eval(attrs.uiCalendar) : {},

(and as noted avobe, I also dropped the curly braces while passing the config object).

I haven't encountered any strange behaviour going with these reverted code, though I don't know why the change was made in the first place.

MaxYari commented 9 years ago

Thank You for the quick reply! =) Will try it out.

rcrodrigues commented 9 years ago

Had the same problem after the update. Spent half a day trying to find the bug O.o Thanks @ChristianSteu !

kristyoverton commented 9 years ago

Thank you! I couldn't get eventClick to respond no matter what I tried, thought I was going crazy.

ggondim commented 9 years ago

Any PR to fix this issue? It realy is a problem with the new directive and this workaround fixed it.

enissay14 commented 9 years ago

I was using the solution: <div ui-calendar="{{configObject}}" but then no callback was fired! changing line 299 fixed it. Thank you

ChristianSteu commented 9 years ago

I might look into doing a PR, but I'm pretty new to GitHub and have basically no clue how to make one ;-).

Also before just reverting the change, I kinda would like to know the reason why the change was made in the first place - maybe there is a valid reason for the change and we need another solution. (Especially since it is/was a breaking change in the config param syntax).

ggondim commented 9 years ago

Maybe the project's main contributor, @jkurz / @joshkurz, could explain why the change was made?

datesss commented 9 years ago

The weird thing for me was that the calendar respected the 'editable' flag in the configuration, but none of the event triggers were working. I changed the line 229 and it worked! whew

joshkurz commented 9 years ago

This should be fixed now. This https://github.com/angular-ui/ui-calendar/commit/b0ec1762f6ea9bf393638c13e62dc3da247bcdd1 was the root cause. It removed the $parent.eval from the evaluation of the config object. I changed the demo as well to not use interpolation on the config as it should be just evaluated straight from the scope.