Skip Navigation

[Resolved] views datepicker

This support ticket is created 4 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by Shane 4 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1228567

Tell us what you are trying to do?
Set the datepicker to default the selected date to 48 hours from the time of clicking the calendar icon, and block selecting anyday prior to 48 hours from now - its a booking which needs some days notice.

Is there any documentation that you are following?
hidden link

Is there a similar example that we can see?

 
jQuery(document).ready(function(){
  jQuery('.js-wpv-date-front-end-wpv-wpcf-test-date').datepicker('option','defaultDate', new Date(new Date().getTime() + 48 * 60 * 60 * 1000));
  jQuery('.js-wpv-date-front-end-wpv-wpcf-test-date').datepicker('option','minDate', new Date(new Date().getTime() + 48 * 60 * 60 * 1000));
}); 

sort of works.... it loses the block after any selection..

but I have been unable to get this to work at all within some other javascript which is getting quite long

{link removed}

{code removed}

What is the link to your site?

#1228676

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bryan,

Thank you for getting in touch.

I'm assuming that you're only referencing to this code here that it stops working after you've made a selection correct?

jQuery(document).ready(function(){
  jQuery('.js-wpv-date-front-end-wpv-wpcf-test-date').datepicker('option','defaultDate', new Date(new Date().getTime() + 48 * 60 * 60 * 1000));
  jQuery('.js-wpv-date-front-end-wpv-wpcf-test-date').datepicker('option','minDate', new Date(new Date().getTime() + 48 * 60 * 60 * 1000));
});

If so then you need to add it to the callback function for the view filters.


jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
  jQuery('.js-wpv-date-front-end-wpv-wpcf-test-date').datepicker('option','defaultDate', new Date(new Date().getTime() + 48 * 60 * 60 * 1000));
  jQuery('.js-wpv-date-front-end-wpv-wpcf-test-date').datepicker('option','minDate', new Date(new Date().getTime() + 48 * 60 * 60 * 1000));
	
});

Please try this and let me know if it helps.

Thanks,
Shane

#1229071

Shane

thanks... I notice a paste error here from my side from the wrong site - can you either delete my earlier update or make it private (as I don't want that link exposed) - while I rewrite the ticket.

thanks

#1229150

Shane - I asked Waqar in my timezone to clean up the erroneous links... you are right about the sample code but I have had no luck with the callback function, I will get back with a result tomorrow. thanks

#1229440

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bryan,

Thanks for the update.

Please let me know the results as soon as possible.

Thanks,
Shane

#1230533

OK I think I understand what's happening now - the problem seems to arise when the types fields and the url param do not match - in which case it appears the url_parameter should be used ?!

If I add a date filter to me view for example:

<div class="form-group">
	<label>[wpml-string context="wpv-views"]TB tbk_date[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-tb-date" url_param="tbk_date"]
</div>

I need to reference the url_param and not the field. for the sake of simplicity in this example I am making the min date 3 days from now disabling any date prior to that

   jQuery('.js-wpv-date-front-end-tbk_date').datepicker('option', 'minDate', 3); 

NOT

   jQuery('.js-wpv-date-front-end-wpv-wpcf-tb-date').datepicker('option', 'minDate', 3); 

and this works fine with the

jQuery(document).ready(function($){

Shane unless I am missing something can you pass this on to the documentation folk ? I found this very frustrating as this relationship is not explained anywhere.

thanks

#1231008

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Brian,

Just for clarity you were able to resolve the issue correct and all that is needed to be done is to document this correct?

Please let me know

#1233369

Shane - yes that's correct

#1234535

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bryan,

Awesome, once we close here what will happen is that this thread will get a Thread Summary which will serve as documentation for other users.

So I will be marking this one as resolved and then add the thread summary.

Thank,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.