Test if start or end is unset then clear hidden input

git-svn-id: https://svn.eudat.eu/EUDAT/Services/MetaData/ckanext-datesearch@2722 68e52488-0a15-44bc-a314-416658652264
This commit is contained in:
Mikael Karlsson 2014-03-11 14:21:50 +00:00
parent e4c6b0452a
commit 9d9ae68788
1 changed files with 10 additions and 2 deletions

View File

@ -52,11 +52,19 @@ this.ckan.module('daterangepicker-module', function ($, _) {
switch (ev.target.name) {
case 'start':
// Set the value of the hidden <input id="ext_startdate"> to the chosen start date.
$('#ext_startdate').val(v.format(fs) + 'Z');
if (ev.date) {
$('#ext_startdate').val(v.format(fs) + 'Z');
} else {
$('#ext_startdate').val('');
}
break;
case 'end':
// Set the value of the hidden <input id="ext_enddate"> to the chosen end date.
$('#ext_enddate').val(v.add('y', 1).subtract('s', 1).format(fs) + 'Z');
if (ev.date) {
$('#ext_enddate').val(v.add('y', 1).subtract('s', 1).format(fs) + 'Z');
} else {
$('#ext_enddate').val('');
}
break;
}