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

Modal.open() opens datapicker instead of modal #5806

Open
d-mance opened this issue Apr 10, 2018 · 3 comments
Open

Modal.open() opens datapicker instead of modal #5806

d-mance opened this issue Apr 10, 2018 · 3 comments

Comments

@d-mance
Copy link

d-mance commented Apr 10, 2018

Expected Behavior

I want to open a modal, but it instead opens a datepicker.

Current Behavior

I use a function to open a modal but it opens a datepicker

Steps to Reproduce (for bugs)

I have a demo on git because I do not know how to make a live demo.

https://github.com/d-mance/angularmaterializebehaviour

Once cloned, type npm install and then npm start to initialize the angular application. Then you should go to http://localhost:4200

Click on a set button that should open a modal and it will open a datepicker instead.

Context

I want to create a start and end date for every item in the model.

Your Environment

@d-mance d-mance changed the title When I try to open a modal it instead open a date picker Modal.open() opens datapicker instead of modal Apr 12, 2018
@Dogfalo
Copy link
Owner

Dogfalo commented Apr 12, 2018

This is likely happening because you are calling .open() on the datepicker instance instead of the modal instance

@d-mance
Copy link
Author

d-mance commented Apr 17, 2018

Hello @Dogfalo ,
Thanks for answer.

Actually I'm calling the modal with:
const instance = M.Modal.init(elem, {opacity: 0});
And the datepicker with function:

private loadDatePickers() {
    this.dataSources.forEach(
      (dataSource) => {
        let datePickers = document.getElementsByClassName('datepicker' + dataSource.id);
        this.datePickers[dataSource.id] = [];
        for (var i = 0; i < datePickers.length; i++) {
          let options = {
            format: 'yyyy-mm-dd',
            firstDay: 1,
            setDefaultDate: true
          }
          let instance = M.Datepicker.init(datePickers[i], options);
          this.datePickers[dataSource.id].push(instance);
        }
      }
    )
  }

@dmancecrg
Copy link

I tried to avoid the use of picker and modal in the same angular 6 component but now i have to use it.

It stills doing the same, when i open a modal it opens a picker.

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