Multiple-Dates-Picker-for-jQuery-UI icon indicating copy to clipboard operation
Multiple-Dates-Picker-for-jQuery-UI copied to clipboard

Can we avoid the calendar from flickering / being redrawn after every selection?

Open rohanabraham opened this issue 12 years ago • 19 comments

The calendar works well generally.

At the moment while selecting dates on the calendar popup, for each click, the calendar is being redrawn. Is it possible to avoid this?

rohanabraham avatar Jul 03 '13 06:07 rohanabraham

I second this. Is there a workaround for this?

vigneshwaranr avatar Oct 24 '13 08:10 vigneshwaranr

Also if I select a date from a month different from the current month, it redraws that month only for the first selection but redraws the current month back in subsequent selections.

Checked in http://multidatespickr.sourceforge.net/#undefined-demo version: 1.6.1

vigneshwaranr avatar Oct 24 '13 11:10 vigneshwaranr

I vote for this issue as well. Selecting a date of different month rather then current month will flicker a bit and shows back the current month.

narramadan avatar Jan 26 '14 15:01 narramadan

please tell me the way to stop the flicker

varshag91 avatar Feb 12 '14 13:02 varshag91

same problem here

johniecco avatar Feb 21 '14 18:02 johniecco

If anyone fixes this, please send a pull request so that it can be used to update the code.

rohanabraham avatar Feb 21 '14 18:02 rohanabraham

The issue is caused by the onSelect native function of the jQuery Datepicker that the code extends. That function causes the calendar to close when a date is picked and MDP adds a short timeout that reopens back the calendar. The solution would be to somehow prevent the close animation to start in the jq Datepicker onSelect.

AlexL avatar May 28 '14 17:05 AlexL

Hey guys, I think this would work best! $('#from-input').multiDatesPicker( onSelect: function() { $(this).data("datepicker").inline = true;
}, onClose: function() { $(this).data("datepicker").inline = false; },

);

Sudhamsha avatar Sep 18 '14 09:09 Sudhamsha

I've succeeded in improving the display reducing the flickering effect but, as it has been said, it is caused by the way the original date picker works. Meanwhile try out the version 1.6.2 :)

dubrox avatar Sep 20 '14 00:09 dubrox

Still not working here. It does not redrawn on first chosen date, but after the second it stills flickering.

johniecco avatar Sep 23 '14 02:09 johniecco

This will do it...

$.datepicker._selectDateOverload = $.datepicker._selectDate; $.datepicker._selectDate = function(id, dateStr) { var target = $(id); var inst = this._getInst(target[0]); inst.inline = true; $.datepicker._selectDateOverload(id, dateStr); inst.inline = false; this._updateDatepicker(inst); };

ojdavey avatar Oct 08 '14 04:10 ojdavey

@ojdavey , yes that works for me. thanks!

apfz avatar Nov 08 '14 11:11 apfz

I also have this problem, if I go to another month I can select up to two dates and it redraws. These fixes are not working I'm using the following code...

jQuery(document).ready(function($) {

    $('#acf-field-all_dates').multiDatesPicker({
        dateFormat: "yy-m-d"
    });

    $.datepicker._selectDateOverload = $.datepicker._selectDate;
    $.datepicker._selectDate = function(id, dateStr) {
    var target = $(id);
    var inst = this._getInst(target[0]);
    inst.inline = true;
    $.datepicker._selectDateOverload(id, dateStr);
    inst.inline = false;
    this._updateDatepicker(inst);
    };
});

anagio avatar Nov 17 '14 21:11 anagio

Got this working, I had to enque my js at a higher priority. It was conflicting with ACF's date picker.

anagio avatar Nov 17 '14 21:11 anagio

Why all complicated solution for such simple issue?

On _hideDatepicker function of multidatepicker, after $.datepicker._updateDatepicker(target); add the following $.datepicker._refreshDatepicker(target);

IamJAX avatar Jan 21 '15 07:01 IamJAX

@anagio solution worked for me, i've just added this line target[0].multiDatesPicker.changed = false; after inst.inline = false; This code avoided 2 clicks outside calendar to close it.

The final code is:

$.datepicker._selectDateOverload = $.datepicker._selectDate;
$.datepicker._selectDate = function (id, dateStr) {
        var target = $(id);
        var inst = this._getInst(target[0]);
        inst.inline = true;
        $.datepicker._selectDateOverload(id, dateStr);
        inst.inline = false;
        target[0].multiDatesPicker.changed = false;
        this._updateDatepicker(inst);
    };

johniecco avatar Apr 06 '15 19:04 johniecco

Problem with the @anagio and @johniecco solution is it overwrites the functionality of ordinary single datepickers. I get an error on this line: target[0].multiDatesPicker.changed = false; as being undefined, when using an ordinary datepicker.

thomstark avatar Apr 29 '15 10:04 thomstark

@thomstark to resolve this problem:

$.datepicker._selectDateOverload = $.datepicker._selectDate;
    $.datepicker._selectDate = function (id, dateStr) {
        var target = $(id);
        var inst = this._getInst(target[0]);
        inst.inline = true;
        $.datepicker._selectDateOverload(id, dateStr);
        inst.inline = false;
        if (target[0].multiDatesPicker != null) {
            target[0].multiDatesPicker.changed = false;
        } else {
            target.multiDatesPicker.changed = false;
        }
        this._updateDatepicker(inst);
    };

victorgsp avatar Sep 17 '15 18:09 victorgsp

@victorgsp it work good. But dafault datepicker don`t autohide on select. I update your code

$.datepicker._selectDateOverload = $.datepicker._selectDate;
$.datepicker._selectDate = function (id, dateStr) {
	var target = $(id);
	var inst = this._getInst(target[0]);
	if (target[0].multiDatesPicker != null) {
		inst.inline = true;
		$.datepicker._selectDateOverload(id, dateStr);
		inst.inline = false;	        	
		target[0].multiDatesPicker.changed = false;
	} else {
		$.datepicker._selectDateOverload(id, dateStr);
		target.multiDatesPicker.changed = false;
	}
	this._updateDatepicker(inst);
}; 

mcvova avatar Aug 10 '17 07:08 mcvova