$(document).ready(function(){ $('select.select-ticket').multilineSelectmenu({ maxHeight: 60 }) .on("change", function(event, param) { //service = $(this).val(); $(this).closest('.table-ticket').find('.error-ticket').hide(); }); $('#form').submit(function(e){ okToPost = true; var ticketDate = Array(); var ticketType = Array(); idx = 0; $('.table-ticket').each(function(){ if($(this).find('.datevalue').val()=='') { $(this).closest('.table-ticket').find('.error-date').show().html("You haven't chosen a date for ticket."); okToPost = false; } var rowTicket = $(this).find('.select-ticket'); if($(this).find('.select-ticket').val()==null) { $(this).closest('.table-ticket').find('.error-ticket').show().html("チケットの種類を選択しませんでした。"); okToPost = false; } ticketDate[idx] = $(this).find('.datevalue').val(); ticketType[idx++] = $(this).find('.select-ticket').val(); }); if(okToPost && ticketDate.length>1) { for(i=0; iチケットの種類を選択してください") .multilineSelectmenu('refresh'); newTicket.find('input.datefield').datepicker(); newTicket.find('.button-del') .show() .on("click", function(event, param) { event.preventDefault(); removeTicket($(this)); }); newTicket .find('input.datepicker') .attr("id", "") .removeClass('hasDatepicker') .removeData('datepicker') .unbind() .datepicker({ dateFormat: 'yy MM dd', altFormat: 'yymmdd', minDate: '+1', maxDate: new Date(2025, 11, 31), defaultDate: '+1', autoSize: true }).each(function() { $(this).datepicker("option", "altField", $(this).next()); $(this).val("日付を選択"); // Choose a date newTicket.find('.datevalue').val(''); }) .on("change", function(event, param) { var currIndex = parseInt(newTicket.find('.title-number').html())-1; var newDate = newTicket.find('.datevalue').val(); populateTicket(newTicket, newDate, currIndex, param); }); newTicket .find('.check-opendate') .prop('checked',false) .on("change", function(event, param) { var checked = ($(this).prop('checked')) ? 1 : 0; $(this).closest('div').find('.opendatevalue').val(checked); }); newTicket.find('.opendatevalue').val(0) newTicket .find('.check-museum') .prop('checked',false) .on("change", function(event, param) { var checked = ($(this).prop('checked')) ? 1 : 0; $(this).closest('div').find('.museumvalue').val(checked); }); newTicket.find('.museumvalue').val(0) }); $('.check-museum').change(function(event) { var checked = ($(this).prop('checked')) ? 1 : 0; $(this).closest('div').find('.museumvalue').val(checked); }); $('.button-del').click(function(event) { event.preventDefault(); removeTicket($(this)); }); function removeTicket(e) { e.parent('div').parent('div').remove(); var ticket = 1; $('.title-number').each(function(){ $(this).html(ticket); $(this).closest('div').find('.title-number').html(ticket++); }); var rowCount = $('#table-options').find('.table-ticket').length; if($('#button-add_ticket').hasClass('disabled')) $('#button-add_ticket').removeClass('disabled'); } $('.ajax-popup').magnificPopup({ type: 'ajax', tClose: "閉じる (Esc)", tLoading: "Loading..." }); });