ui-calendar icon indicating copy to clipboard operation
ui-calendar copied to clipboard

Changed ui-calendar config doesn't pass functions

Open ChristianSteu opened this issue 11 years ago • 12 comments

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.

ChristianSteu avatar Jul 15 '15 08:07 ChristianSteu

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

MCSCC avatar Jul 17 '15 05:07 MCSCC

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

MaxYari avatar Jul 19 '15 23:07 MaxYari

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.

ChristianSteu avatar Jul 20 '15 08:07 ChristianSteu

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

MaxYari avatar Jul 20 '15 09:07 MaxYari

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

rcrodrigues avatar Jul 28 '15 13:07 rcrodrigues

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

kristyoverton avatar Aug 05 '15 17:08 kristyoverton

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

ggondim avatar Aug 14 '15 13:08 ggondim

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

enissay14 avatar Aug 15 '15 11:08 enissay14

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).

ChristianSteu avatar Aug 17 '15 14:08 ChristianSteu

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

ggondim avatar Aug 17 '15 19:08 ggondim

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

datesss avatar Aug 18 '15 19:08 datesss

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.

joshkurz avatar Aug 18 '15 20:08 joshkurz