• Daedalon

    (@daedalon)


    Having start and end date in separate TR elements currently breaks the date range support. This is due to an unnecessarily strict selector for endDate. As a result the minDate for end date is not set, and selecting a start date doesn’t update end date even. Both can result in events ending before they start.

    The selector below fixes these issues.

    Example HTML

    <tr class="em-date-range em-date-range-start">
    	<td>
    		<span class="em-recurring-text">...</span>
    		<span class="em-event-text">...</span>
    	</td>
    	<td>
    		<input class="em-date-start em-date-input-loc" type="text" />
                    <input class="em-date-input" type="hidden" name="event_start_date" value="" />
    	</td>
    </tr>
    <tr class="em-date-range em-date-range-end">
    	<td>
    		<span class="em-recurring-text">...</span>
    		<span class="em-event-text">...</span>
    	</td>
    		<input class="em-date-end em-date-input-loc" type="text" />
                    <input class="em-date-input" type="hidden" name="event_end_date" value="" />
    	</td>
    </tr>

    Current, problematic selector

    var endDate = startDate.parents('.em-date-range').find('.em-date-end').first();

    Improved, looser selector

    var endDate = startDate.closest('.event-form-times').find('.em-date-end').first();

    https://wordpress.org/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • caimin_nwl

    (@caimin_nwl)

    Thanks, I’ll pass this along to the Dev team.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Thanks for the suggestion, but I this could potentially give problems when you have more than one date-range picker in the same page.

    I would say to wrap the whole thing in a tbody tag instead. so this should work and is valid HTML:

    <tbody class="em-date-range">
    <tr class="em-date-range-start">
    	<td>
    		<span class="em-recurring-text">...</span>
    		<span class="em-event-text">...</span>
    	</td>
    	<td>
    		<input class="em-date-start em-date-input-loc" type="text" />
                    <input class="em-date-input" type="hidden" name="event_start_date" value="" />
    	</td>
    </tr>
    <tr class="em-date-range-end">
    	<td>
    		<span class="em-recurring-text">...</span>
    		<span class="em-event-text">...</span>
    	</td>
    		<input class="em-date-end em-date-input-loc" type="text" />
                    <input class="em-date-input" type="hidden" name="event_end_date" value="" />
    	</td>
    </tr>
    </tbody>
    Thread Starter Daedalon

    (@daedalon)

    Hi, thanks for the reply. Are there use cases where there are more than one pair of date-range pickers within the same .event-form-times? I can’t think of any.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[PATCH] Allow start and end date in separate TRs’ is closed to new replies.