Paul-DS / bootstrap-year-calendar

[DEPRECATED] A fully customizable year calendar widget, for boostrap !
Apache License 2.0
294 stars 243 forks source link

disabled months problem #149

Open korkuttaha opened 7 years ago

korkuttaha commented 7 years ago

Hello,

This code works for passed months but it disables passed months for 2018 aswell. It should disable January, February, March, April, May for 2017 but not for 2018

renderEnd: function (e) { var currentMonth = new Date().getMonth(); $('#calendar .month-container').each(function (idx, el) { if (idx < currentMonth) { $(this).css("display", "none"); } if (idx > currentMonth + 12) { $(this).css("display", "none"); } }); },

Thanks in advance

William-H-M commented 7 years ago

Hi the reason because of this is quite simple you have a condition that say

if (idx < currentMonth ) { 
$(this).css("display", "none");
 }

Basically you're telling that if we're on February of whatever year it'll hide January, what you should do is just compare with current year and month number

Another way around is just load current year and avoid that the clients change years

korkuttaha commented 7 years ago

is it possible for you to write that condition for me?.. :) if it would not be so much pain :)

Thanks in advance