twitter bootstrap - daterangepicker - set only one date range (from/to) -
using daterangepicker i'm trying found solution as:
00/00/0000 - 26/06/2014 or 26/06/2014 - 00/00/0000
i can't add 0 or checkbox set date 'unlimited' or end of date.
how set date on 1 (from or to)?
found lazy solution due lack of functionality , submit github add feature unlimited daterange:
$('#dpdiv').daterangepicker({ 'applyclass' : 'btn-sm btn-success', 'cancelclass' : 'btn-sm btn-default', format: 'l', showdropdowns: true, showweeknumbers: true, singledatepicker: false }, function(start, end, label) { // not used }) .prev().on(ace.click_event, function(){ $(this).next().focus(); }); $("body .daterangepicker .ranges .range_inputs button").first().before('<div><a href="#" id="daterangepicker_clear_start_date"> - ∞</a><br />'); $("body .daterangepicker .ranges .range_inputs button").first().before('<div><a href="#" id="daterangepicker_clear_end_date"> - ∞</a><br /><br />'); $('#dpdiv').on('apply.daterangepicker', function(ev, picker) { var drp_from = $('body .daterangepicker .ranges .daterangepicker_start_input input').val(); var drp_to = $('body .daterangepicker .ranges .daterangepicker_end_input input').val(); if (drp_from.length == 0) { $(this).val("---- - " + picker.enddate.format('l')); $("#dpr_hidden_div_start").val(""); $("#dpr_hidden_div_end").val(picker.enddate.format('l')); } if (drp_to.length == 0) { $(this).val(picker.enddate.format('l') + "- ----"); $("#dpr_hidden_div_start").val(picker.startdate.format('l')); $("#dpr_hidden_div_end").val(""); } if (drp_from.length == 0 && drp_to.length == 0) { $(this).val(""); $("#dpr_hidden_div_start").val(""); $("#dpr_hidden_div_end").val(""); } }); $('#dpdiv').on('cancel.daterangepicker', function(ev, picker) { $('#dpdiv').val(''); //clear }); $("#dpr_hidden_div_start").on('click', function(){ $('body .daterangepicker .ranges .daterangepicker_start_input input').val(""); }); $("#daterangepicker_clear_end_date").on('click', function(){ $('body .daterangepicker .ranges .daterangepicker_end_input input').val(""); });
Comments
Post a Comment