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

Next and Back button click event not working #481

Open
NIYASSURABHI opened this issue Dec 2, 2019 · 11 comments
Open

Next and Back button click event not working #481

NIYASSURABHI opened this issue Dec 2, 2019 · 11 comments

Comments

@NIYASSURABHI
Copy link

NIYASSURABHI commented Dec 2, 2019

I'am using two arrow buttons to navigate next/prev month. using

var mySwiper = document.querySelector('.swiper-container')['swiper'];
mySwiper.slideNext();

But its not working in my ionic4 (Angular8) Application. Please help me on this

@twinssbc
Copy link
Owner

twinssbc commented Dec 2, 2019

@NIYASSURABHI How is it not working? Any error message printed out in the console? This is just a simply DOM query, could you check the DOM structure to if the queried element exists ('.swiper-container')?

@NIYASSURABHI
Copy link
Author

@NIYASSURABHI How is it not working? Any error message printed out in the console? This is just a simply DOM query, could you check the DOM structure to if the queried element exists ('.swiper-container')?

When i console the swiper , the active index is changing. But view is not changing. Normal swiping is working

@NIYASSURABHI
Copy link
Author

I have fixed this issue by changing current date as you said in another issue.
this.calendar.currentDate = new Date(this.calendar.currentDate.setMonth(this.calendar.currentDate.getMonth() + 1));

But i noticed another situation that, when i click right navigation from January 31 its showing march 2 (because February have only 29 days) .this issue is happening on several months because some have 30 and some have 31. How can i handle this situation?

@twinssbc
Copy link
Owner

twinssbc commented Dec 4, 2019

@NIYASSURABHI You could set the date to some day in the middle of the month so that it won't cause such edge case. Another way is you could check after setting the month, whether the month is the expected one, if not, adjust the date to the expected month.

@NIYASSURABHI
Copy link
Author

@NIYASSURABHI You could set the date to some day in the middle of the month so that it won't cause such edge case. Another way is you could check after setting the month, whether the month is the expected one, if not, adjust the date to the expected month.

Do u have any workaround to handle this. it will be very helpful for me

@NIYASSURABHI
Copy link
Author

"Another way is you could check after setting the month, whether the month is the expected one, if not, adjust the date to the expected month."

How can i do this? Can u please give a guidance?

@NIYASSURABHI
Copy link
Author

var cuurentday=this.calendar.currentDate;
let currentMonth = cuurentday.getMonth();
let nextMonth = new Date(cuurentday.setMonth(cuurentday.getMonth() + 1));
debugger

if(nextMonth.getMonth()-currentMonth>1){
  this.calendar.currentDate = new Date(this.calendar.currentDate.getFullYear(),currentMonth+1, 0);
 }
 else{

  this.calendar.currentDate = new Date(this.calendar.currentDate.setMonth(this.calendar.currentDate.getMonth() + 1));

// }

i have tried with this logic..but its jumping to next 2 months

@Fresh-Dev-zunairzakir
Copy link

Fresh-Dev-zunairzakir commented Dec 6, 2019

I am also getting the below error when clicking on next or previous:
ERROR TypeError: Cannot read property 'swiper' of null

And I am also not able to see any generated elements inside the DOM.
image

Please guide me in this.

@twinssbc
Copy link
Owner

twinssbc commented Dec 9, 2019

@Fresh-Dev-zunairzakir Did you import the NgCalendarModule in module file? This looks like the calendar element is not recognized.

@twinssbc
Copy link
Owner

twinssbc commented Dec 9, 2019

@NIYASSURABHI You need to add more logic to avoid edge case, for example always set the date to some day in the middle of the month, instead the first and last day.
For example, new Date(2019,01,31) return Mar 03, instead of some day in Febuary.

@insidew
Copy link

insidew commented Dec 18, 2019

Do you sloved this problem ? I have also problem with next prev button navigation. Sometimes it works but mostly not...
it's hard to say why it's false..

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

4 participants