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

Datepicker handlers #47

Closed
pchristou opened this issue Jun 14, 2016 · 3 comments
Closed

Datepicker handlers #47

pchristou opened this issue Jun 14, 2016 · 3 comments

Comments

@pchristou
Copy link

Hi,

In short, I have 2 questions.

  1. How can I close the datepicker on selection?
  2. Why does this datepicker implementation not suffer from this bug whereas Materialize's one (and mine) does?

Longer explanation:

I understand Materialize uses pickadate.js under the covers. Having checked its API I see there are a range of event callbacks available:
callback_handlers

How can I apply these to the datepicker in Angular 2? I got as far as grabbing the datepicker through

        var $input =$(this.el.nativeElement); // We grab a reference to the datepicker here
        var picker = $input.pickadate('picker');

but there's not a great deal I can do from there. I actually want to close the datepicker on selection and found that an attribute 'closeOnSelect' exists: http://amsul.ca/pickadate.js/date/

Unfortunately, placing this in [materializeParams] doesn't seem to work.

One more thing, I noticed the Datepicker sample here http://angular2-materialize.surge.sh/#/datepicker
does not suffer from this bug whereas Materializes (plus mine) does... can you think of any reasons why? I thought the implementation between both would be near identical...

As always, thank you!
Pieris

@pchristou
Copy link
Author

Got this sorted.

For the date handling part, I used:


        var $input = $(this.el.nativeElement); // We grab a reference to the datepicker here
        var picker = $input.pickadate('picker');
        picker.on('close', function() {
          //...
        })

@marciomsm
Copy link

Are we able to use events callback already? Do anyone knows how to do it in Angular 2?

@rubyboy
Copy link
Contributor

rubyboy commented Jun 17, 2017

See here: #283

<input materialize="pickadate" [materializeActions]="actions" type="text" />
this.actions.emit({action:"pickadate",params:["close"]});

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