user2145488 user2145488 - 3 days ago 5
jQuery Question

DatePicker: combine quarterly picker with submit functionality

How to combine a quarter datePicker

(see: SO: how-to-change-bootstrap-datepicker-month-view-to-display-quarters

jsfiddle: http://jsfiddle.net/4mwk0d5L/1/ )

with a submit functionality?

(like: SO: bootstrap-datepicker-how-to-send-value-to-url?)

I tried:

$('#example1').datepicker({
format: "MM yyyy",
minViewMode: 1,
autoclose: true,
language: "qtrs",
forceParse: false
}).on("show", function (event) {

$(".month").each(function (index, element) {
if (index > 3) $(element).hide();
});
}).on('changeDate', function () {
$(this).parent('form').submit();
});


but it does not seem to work.

Here is the jsFiddle I have used:
http://jsfiddle.net/a1t465c7/

Answer

Yes, It should work. Content inside changeDate event is executed. Try this:

$('#example1').datepicker({
    format: "MM yyyy",
    minViewMode: 1,
    autoclose: true,
    language: "qtrs",
    forceParse: false
}).on("show", function (event) {

    $(".month").each(function (index, element) {
        if (index > 3) $(element).hide();
    });
}).on('changeDate', function () {
    alert('test');
});

See here: http://jsfiddle.net/76Lhvfy0/

May be a problem with the following instruction:

$(this).parent('form').submit();
Comments