2015-11-04 65 views
1

您好我有這樣的fullcalendar代碼:如何在fullcalendar的每一天添加一個ID?

calendar: function(datos,rut,nombre){ 

    var self = this; 

    $('#calendar').fullCalendar({ 

     height: 500, 
     events: datos, 
     editable: true, 

      header: { 
       left: '', 
       center: 'prev title next', 
       right: '', 
      }, 

     eventRender: function (event, element) { 
      var self = this; 
      element.find('.fc-title').append(" (<strong>"+ event.estado +"</strong>)"); 
     }, 

     viewRender: function (view) { 

     $('.fc-day-number').prepend("<button type='button' style='margin-right:5px; padding:0; border: none; background: none;' id ='editar_control_id' class='btn btn-default addButton' title='Ver/Editar'><i class='fa fa-eye'></i></button>"); 

     }, 

    }) 

    $('#calendar').fullCalendar('removeEvents'); 
    $('#calendar').fullCalendar('addEventSource', datos);   
    $('#calendar').fullCalendar('rerenderEvents');   
}, 

使用viewRender我的每一天:

viewRender: function (view) { 


     $('.fc-day-number').prepend("<button type='button' style='margin-right:5px; padding:0; border: none; background: none;' id ='editar_control_id' class='btn btn-default addButton' title='Ver/Editar'><i class='fa fa-eye'></i></button>"); 


     }, 

所以添加一個按鈕,我想每個按鈕有一天像編號:

例如:

id ='editar_control_2015-09-04_id'

這是日曆:

enter image description here

我怎樣才能做到這一點?對不起我的英語。

回答

1

使用的DayRender VS viewRender

dayRender: function (date, cell) { 
    // The cell has a data-date tag with the date we can use vs date.format('YYYY-MM-DD') 
    var theDate = $(cell).data('date'); 
    // Find the day number td for the date 
    var fcDaySkel = $("#calendar div.fc-content-skeleton td[data-date='"+theDate+"'].fc-day-number"); 
    fcDaySkel.prepend("<img src='http://icons.iconarchive.com/icons/glyphish/glyphish/24/12-eye-icon.png' id='editar_control_"+theDate+"_id'/>"); 
} 

http://jsfiddle.net/14frdxf2/2/

這撥弄使用IMG而不是按鈕,但做法應該是相同的

+0

完美!謝謝! – Jeanbf

+0

你能幫我解決嗎? http://stackoverflow.com/questions/33551640/how-use-fullcalendar-with-a-dropdown-correctly – Jeanbf

相關問題