Paul-DS / bootstrap-year-calendar

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

yearChanged doesn't work #139

Closed Dreambox13 closed 7 years ago

Dreambox13 commented 7 years ago

Im trying to use yearChanged method but the function never triggers. The calendar appear in the screen but the method doen't fired. Please help me.

Here is my code:

html

<div id="calendar"></div>

js code

var currentYear = new Date().getFullYear();
    var calendar = $('#calendar').calendar({
        yearChanged: function(e) {
            e.preventRendering = true;
            alert('yearChanged');
        }
    });

calendar.setYear(currentYear);
William-H-M commented 7 years ago

Hi, Ok that's kinda weird but lets do this, in this try of example repo dowload the files of the year calendar, maybe could be because do you have an older release, if this do not help please can you share a part of your code, can be linked to a fiddle or just load the files here and we'll see what's going on

Dreambox13 commented 7 years ago

Hello, you saved my life. @William-H-M I downloaded your repo I added the files of the calendar and some how my code works. Maybe I had wrong release.

Thank you very much

William-H-M commented 7 years ago

Hi, great maybe it was and older release as you said, now as this is solved, close this issue.

If any other problem just ask :)

subvillion commented 7 years ago

Release downloaded from http://www.bootstrap-year-calendar.com/#Download dons't have yearChanged implementation.

William-H-M commented 7 years ago

Hi, @x0x01 can you please download the file from the repo as on the page is not updated, if not wrong.

In the repo we have if(opt.yearChanged) { this.element.bind('yearChanged', opt.yearChanged); }

But on the page just

if(opt.renderEnd) { this.element.bind('renderEnd', opt.renderEnd); }
if(opt.clickDay) { this.element.bind('clickDay', opt.clickDay); }
if(opt.dayContextMenu) { this.element.bind('dayContextMenu', opt.dayContextMenu); }
if(opt.selectRange) { this.element.bind('selectRange', opt.selectRange); }
if(opt.mouseOnDay) { this.element.bind('mouseOnDay', opt.mouseOnDay); }
if(opt.mouseOutDay) { this.element.bind('mouseOutDay', opt.mouseOutDay); }
thaqiftaher commented 5 years ago

Hi there,

I wanted to store the year every time the yearChanged is fired. This is the my code:

yearChanged: function(e)
        {
            var tahun = $('#calendar').data('calendar').getYear();
            alert(tahun);
        },

However, the calendar is not displayed. When i opened the console, this is the error:

Uncaught TypeError: Cannot read property 'getYear' of undefined
    at HTMLDivElement.yearChanged (conv-calendar.html:33)
    at HTMLDivElement.dispatch (jquery-2.2.3.min.js:3)
    at HTMLDivElement.r.handle (jquery-2.2.3.min.js:3)
    at Object.trigger (jquery-2.2.3.min.js:4)
    at HTMLDivElement.<anonymous> (jquery-2.2.3.min.js:4)
    at Function.each (jquery-2.2.3.min.js:2)
    at n.fn.init.each (jquery-2.2.3.min.js:2)
    at n.fn.init.trigger (jquery-2.2.3.min.js:4)
    at b._triggerEvent (bootstrap-year-calendar.min.js:7)
    at b.setYear (bootstrap-year-calendar.min.js:7)

Is there any way to achieve this?