Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

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

Open
ChristianSteu opened this issue Jul 15, 2015 · 12 comments
Open

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

ChristianSteu opened this issue Jul 15, 2015 · 12 comments

Comments

@ChristianSteu
Copy link

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
Copy link

MCSCC commented Jul 17, 2015

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

@MaxYari
Copy link

MaxYari commented Jul 19, 2015

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
Copy link
Author

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
Copy link

MaxYari commented Jul 20, 2015

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

@rcrodrigues
Copy link

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

@kristyoverton
Copy link

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

@ggondim
Copy link

ggondim commented Aug 14, 2015

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

@enissay14
Copy link

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

@ChristianSteu
Copy link
Author

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
Copy link

ggondim commented Aug 17, 2015

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

@datesss
Copy link

datesss commented Aug 18, 2015

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
Copy link
Contributor

This should be fixed now. This b0ec176 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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants