Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cookbook recipe nav with select calendar.center.clone is not a function #203

Open
sumeetattree opened this issue Mar 6, 2019 · 3 comments

Comments

@sumeetattree
Copy link

While trying to use the changeCenter example using a select dropdown I run into this issue. Are you expecting calendar.center to be a moment() instance? I think it's plain javascript date object.

https://ember-power-calendar.com/cookbook/nav-select

Here's the error captured from the above url

Uncaught TypeError: n.center.clone is not a function
    at r.changeCenter (dummy-39fd95360d0a4ddd00da302f5583ae7f.js:43)
    at e._run (vendor-b044936eba6b0c8245ba96e2477ca231.js:3112)
    at e._join (vendor-b044936eba6b0c8245ba96e2477ca231.js:3111)
    at e.join (vendor-b044936eba6b0c8245ba96e2477ca231.js:3077)
    at d (vendor-b044936eba6b0c8245ba96e2477ca231.js:2187)
    at vendor-b044936eba6b0c8245ba96e2477ca231.js:807
    at u (vendor-b044936eba6b0c8245ba96e2477ca231.js:2096)
    at HTMLSelectElement.<anonymous> (vendor-b044936eba6b0c8245ba96e2477ca231.js:807)
@danielrestrepo
Copy link

Hi @sumeetattree

I sorted out the issue making sure that calendar.center is a moment() object:

changeCenter(unit, calendar, e) {
      const date = moment(calendar.center);
      let newCenter = date.clone()[unit](e.target.value);
      calendar.actions.changeCenter(newCenter);
}

@stuartg99
Copy link

This is actually broken in the demo site too.

@stuartg99
Copy link

This worked for me:

const date = moment(calendar.center);
let newCenter = date.clone()unit;
calendar.actions.changeCenter(newCenter);

Also, the snippet has 'years' and is missing the 'groupedYears syntax.

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

No branches or pull requests

3 participants