Forums › Forums › Search & Filter Pro › Search by date for ancient documents
- This topic has 57 replies, 2 voices, and was last updated 6 years, 3 months ago by Anonymous.
-
Trevor(Private) August 9, 2018 at 5:56 pm #184999
OK, see the code on this page:
http://newspapers1908.tolstoy.ru/wp-admin/post.php?post=233&action=edit
The list of dates are those with NO documents (and are disabled).
As it is now, the datepicker month year are back and forwards. Before the month was dropdown and year was locked. Either is possible. Which do you want?
You disable a new date by adding it. You enable a date by removing it.
The basic code is this:
var $myBadDates = new Array("01/01/1908", ...list of dates... "31/12/1908" ); function checkBadDates(mydate){ var $return=true; var $returnclass ="available"; $checkdate = jQuery.datepicker.formatDate('dd/mm/yy', mydate); for(var i = 0; i < $myBadDates.length; i++) { if($myBadDates[i] == $checkdate) { $return = false; $returnclass= "unavailable"; } } return [$return,$returnclass]; } jQuery(document).on("sf:init", ".searchandfilter", function(){ jQuery("#search-filter-form-108 .sf-datepicker").datepicker("destroy"); jQuery("#search-filter-form-108 .sf-datepicker").datepicker({ dateFormat: 'dd/mm/yy', yearRange: '1908:1908', defaultDate: '1/1/1908', beforeShowDay: checkBadDates }); }); jQuery(document).on("sf:ajaxfinish", ".searchandfilter", function(){ jQuery("#search-filter-form-108 .sf-datepicker").datepicker("destroy"); jQuery("#search-filter-form-108 .sf-datepicker").datepicker({ dateFormat: 'dd/mm/yy', yearRange: '1908:1908', defaultDate: '1/1/1908', beforeShowDay: checkBadDates }); });
Anonymous(Private) August 10, 2018 at 10:34 am #185085> Can you give me a date to test with where there is already a document entered in WordPress so I can test with that?
1/08/1908, for example.
> I looked at this again this morning. It all seems to be working, yes?
Yes, with the exception of Ajax displaying of the results. But if it’s hard to do, I can disable Ajax for the entire form.
Thank You!
-
AuthorPosts