Skip to content

Instantly share code, notes, and snippets.

@estruyf
Created January 28, 2015 09:51
Show Gist options
  • Select an option

  • Save estruyf/a5e5aeefef4104707ee7 to your computer and use it in GitHub Desktop.

Select an option

Save estruyf/a5e5aeefef4104707ee7 to your computer and use it in GitHub Desktop.
Range Filter with datepicker code
$includeCSS(this.url, 'https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css');
RegisterSod('jquery-1.11.0.min.js', "//code.jquery.com/jquery-1.11.0.min.js");
RegisterSod('jquery-ui.min.js', '//code.jquery.com/ui/1.11.1/jquery-ui.min.js');
RegisterSodDep('jquery-ui.min.js', 'jquery-1.11.0.min.js');
Type.registerNamespace('estruyf.range');
estruyf.range.datepicker = function() {
var container = {};
var format = "yy-mm-dd";
var init = function (controlID, fromInput, toInput) {
// Store the IDs in a container variable
container[controlID] = {};
container[controlID]["from"] = fromInput;
container[controlID]["to"] = toInput;
// Check if jQuery and jQuery UI is loaded
if (typeof jQuery !== 'undefined' && typeof jQuery.ui !== 'undefined') {
show(controlID);
} else {
// Load jQuery and jQuery UI
EnsureScriptFunc("jquery-ui.min.js", null, function() {
show(controlID);
});
}
},
show = function (controlID) {
$('#' + container[controlID].from).datepicker({ dateFormat: format });
$('#' + container[controlID].to).datepicker({ dateFormat: format });
};
return {
init: init
};
}();
Srch.U.registerRenderTemplateByName("daterange_init", estruyf.range.datepicker.init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment