Serhioromano / bootstrap-calendar

Full view calendar with year, month, week and day views based on templates with Twitter Bootstrap.
http://bootstrap-calendar.eivissapp.com/
MIT License
3.02k stars 1.29k forks source link

how to get date from day view #769

Closed tonspeed closed 3 years ago

tonspeed commented 4 years ago

Hi, //When click on hour in the day view var date = $(this).data(\'calendar-day\'); console.log(date);

date is undefined, what's wrong, how to get date from this view?

tonspeed commented 4 years ago

I've made own workaround, not so pretty, but works: modyfy template day.html, add:

<div style="display:none;" class="dzien"><%= cal.options.day %></div>

before this line:

<div class="span1 col-xs-1"><b><%= cal._hour(i, l) %></b></div>

in calendar:

onAfterViewLoad: function(view) {
 $(\'.page-header h3\').text(this.getTitle());
 $(\'.btn-group button\').removeClass(\'active\');
 $(\'button[data-calendar-view="\' + view + \'"]\').addClass(\'active\');
//-------------------------------------------------------------------------------
$(\'#cal-day-box #cal-day-panel #cal-day-panel-hour .cal-day-hour .row-fluid.cal-day-hour-part\').unbind(\'click\');
$(\'#cal-day-box #cal-day-panel #cal-day-panel-hour .cal-day-hour .row-fluid.cal-day-hour-part\').click( function() {
//When click on hour in the day view
var date = $(this).children(\'.dzien\').html();
var time = $(this).children(\'.span1\').children(\'b\').html();
NewEvent(date, time);
});
},
Serhioromano commented 3 years ago

Good.