Paul-DS / bootstrap-year-calendar

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

Not able fire the clickDay event inside the calendar at initialization #152

Open kundan52 opened 7 years ago

kundan52 commented 7 years ago

I am trying to fire the clickDay event inside the calendarat initialization but its not working but same thing if I do with jQuery classic method to bind method on calendar events, its working! Note: I have commented the jQuery classic method to bind Here Is the code

$(function() {
    var currentYear = new Date().getFullYear();
var datas =  [
            {
                id: 0,
                name: 'Google I/O',
                location: 'San Francisco, CA',
                startDate: new Date(currentYear, 4, 28),
                endDate: new Date(currentYear, 4, 28),
                color: '#767676'
            },
            {
                id: 1,
                name: 'Microsoft Convergence',
                location: 'New Orleans, LA',
                startDate: new Date(currentYear, 2, 16),
                endDate: new Date(currentYear, 2, 16),
                color: '#676767'
            }
        ]
    $('#calendar').calendar({ 
         clickDay: function(e) {
             alert("sdtgfyh");
             var yclick=e.date.getFullYear();
             //console.log($(e.element).hasClass("day-start"));
             console.log(yclick);
         },
        enableContextMenu: true,
        style: "background",
        contextMenuItems:[
            {
                text: 'Mark',
                click: editMark
            },
            {
                text: 'Un Mark',
                click: deleteMark
            }
        ],

        selectRange: function(e) {
            editMark({ startDate: e.startDate, endDate: e.endDate });
        },
        mouseOnDay: function(e) {
            if(e.events.length > 0) {
                var content = '';

                $(e.element).popover({ 
                    trigger: 'manual',
                    container: 'body',
                    html:true,
                    content: content
                });

                //$(e.element).popover('show');
            }
        },
        mouseOutDay: function(e) {
            if(e.events.length > 0) {
                $(e.element).popover('hide');
            }
        },
        dayContextMenu: function(e) {
            $(e.element).popover('hide');
        },
        dataSource:datas,
        enableRangeSelection:(datas[0].color)

    });

    $('#save-event').click(function() {
        saveMark();
    });

    /* $('#calendar').clickDay(function(e){ 
    console.log($(e.element).hasClass("day-start"));
     var dayStartVal = $(e.element).hasClass("day-start");
        if(dayStartVal){
            $('#event-modal').modal("hide");
        }    
     });*/

});