Как присвоить active js?

Есть календарь если кликаешь по дню то он становиться активным и выезжает блок с контентом, как делать что бы был активный сегодняшний день при загрузке страницы ?
$('.booked-calendar-wrap').on('click', 'tr.week td', function(e) {

			e.preventDefault();

			var $thisDate 			= $(this),
				$thisRow			= $thisDate.parent(),
				date				= $thisDate.attr('data-date'),
				booked_ajaxURL		= $('#data-ajax-url').html(),
				calendar_id			= $thisDate.parents('table.booked-calendar').attr('data-calendar-id'),
				colspanSetting		= $thisRow.find('td').length;

			if ($thisDate.hasClass('blur') || $thisDate.hasClass('booked') || $thisDate.hasClass('prev-date')){

				// Do nothing.

			} else if ($thisDate.hasClass('active')){

				$thisDate.removeClass('active');
				$('tr.entryBlock').remove();

			} else {

				$('tr.week td').removeClass('active');
				$thisDate.addClass('active');

				$('tr.entryBlock').remove();
				$thisRow.after('<tr class="entryBlock loading"><td colspan="'+colspanSetting+'"></td></tr>');
				$('tr.entryBlock').find('td').spin('booked');

				booked_load_calendar_date_booking_options = {'load':'calendar_date','date':date,'calendar_id':calendar_id};

				/*
				 * allow other script to apply their modification before loading the booking options
				 * $(document).on("booked-before-loading-calendar-booking-options", function(event, params) { code goes here });
				 */
				$(document).trigger("booked-before-loading-calendar-booking-options");

				$('tr.entryBlock').find('td').load(booked_ajaxURL, booked_load_calendar_date_booking_options, function(){
					$('tr.entryBlock').removeClass('loading');
					$('tr.entryBlock').find('.booked-appt-list').fadeIn(300);
					$('tr.entryBlock').find('.booked-appt-list').addClass('shown');
					adjust_calendar_boxes();
				});

			}

			adjust_calendar_boxes();
			return false;

		});
  • Вопрос задан
  • 362 просмотра
Решения вопроса 1
@xFreake Автор вопроса
// Calendar Date Click
		$('.booked-calendar-wrap').on('click', 'tr.week td', function(e) {

			e.preventDefault();

			var $thisDate 			= $(this),
				$thisRow			= $thisDate.parent(),
				date				= $thisDate.attr('data-date'),
				booked_ajaxURL		= $('#data-ajax-url').html(),
				calendar_id			= $thisDate.parents('table.booked-calendar').attr('data-calendar-id'),
				colspanSetting		= $thisRow.find('td').length;

			if ($thisDate.hasClass('blur') || $thisDate.hasClass('booked') || $thisDate.hasClass('prev-date')){

				// Do nothing.

			} else if ($thisDate.hasClass('active')){

				$thisDate.removeClass('active');
				$('tr.entryBlock').remove();

			} else {

				$('tr.week td').removeClass('active');
				$thisDate.addClass('active');

				$('tr.entryBlock').remove();
				$thisRow.after('<tr class="entryBlock loading"><td colspan="'+colspanSetting+'"></td></tr>');
				$('tr.entryBlock').find('td').spin('booked');

				booked_load_calendar_date_booking_options = {'load':'calendar_date','date':date,'calendar_id':calendar_id};

				/*
				 * allow other script to apply their modification before loading the booking options
				 * $(document).on("booked-before-loading-calendar-booking-options", function(event, params) { code goes here });
				 */
				$(document).trigger("booked-before-loading-calendar-booking-options");

				$('tr.entryBlock').find('td').load(booked_ajaxURL, booked_load_calendar_date_booking_options, function(){
					$('tr.entryBlock').removeClass('loading');
					$('tr.entryBlock').find('.booked-appt-list').fadeIn(300);
					$('tr.entryBlock').find('.booked-appt-list').addClass('shown');
					adjust_calendar_boxes();
				});

			}

			adjust_calendar_boxes();
			return false;

		});
		var date = new Date(),
			day = date.getDate();

		var today = day;
		$(".number").each(function() {
			if ($(this).text() == today) {

				$(this).closest('td').trigger('click');


			}
		});
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы