Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event show.datetimepicker not working #227

Open
Ichigo85 opened this issue Jan 4, 2019 · 14 comments
Open

Event show.datetimepicker not working #227

Ichigo85 opened this issue Jan 4, 2019 · 14 comments

Comments

@Ichigo85
Copy link

Ichigo85 commented Jan 4, 2019

Hi, as shown in this fiddle

https://jsfiddle.net/y81Lkv9c/1/

the event show.datetimepicker is never triggered.

@Starzu
Copy link

Starzu commented Jan 7, 2019

Probably releated: #190

@Muspi
Copy link

Muspi commented Jan 14, 2019

Hello, I have the same problem with version 5.1.2

@Ichigo85
Copy link
Author

Yeah, I tested it and it is related to that issue, but why is it merged and closed if it's not?

@lyhung009
Copy link

It looks like this repo is not maintained anymore.

@i-cant-git
Copy link

I have the same issue, please fix! @Eonasdan

@bmampaey
Copy link

bmampaey commented Mar 5, 2019

Same, can you please fix it.

@jjaun
Copy link

jjaun commented Apr 17, 2019

Bug is still in version 5.1.3, any update soon? or remove it from the docs if there will be no fix?

@avan06
Copy link

avan06 commented May 28, 2019

#45 (comment)

Show.datetimepicker event which has no parameters(data),
  this._notifyEvent({type: DateTimePicker.Event.SHOW});

_notifyEvent function of DateTimePicker processing the show event will go wrong,
modified it to @ronaldfenner version will work properly.

@shaan1974
Copy link

Quick fix into function "_notifyEvent ".

DateTimePicker.prototype._notifyEvent = function _notifyEvent(e) {
        
            if ( e.type === "show.datetimepicker" ) 
            {
            }
            else if (e.type === DateTimePicker.Event.CHANGE && (e.date && e.date.isSame(e.oldDate)) || !e.date && !e.oldDate) {
                return;
            }
            this._element.trigger(e);
        };

@lesilent
Copy link

lesilent commented Oct 4, 2019

I've run into this same issue, along with a related issue where I wanted the change.datetimepicker event to be triggered when the date is cleared using the clear button. But because e.date is false when the date is cleared, the function returns and the event never gets cleared. Looking at quick fix by @shaan1974 , I think the issue could actually be fixed by simply moving a parenthesis! My fix (without needing to update the source) is below. Notice the placement of the parentheses when compared to original.

jQuery.fn.datetimepicker.Constructor.prototype._notifyEvent = function _notifyEvent(e) {
	if (e.type === jQuery.fn.datetimepicker.Constructor.Event.CHANGE && (e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate))
	{
		return;
	}
	this._element.trigger(e);
};

@david-offord
Copy link

Just wanted to give a huge shoutout to @shaan1974 , that solution worked for me. Thank you !

@sephi0485
Copy link

I've run into this same issue, along with a related issue where I wanted the change.datetimepicker event to be triggered when the date is cleared using the clear button. But because e.date is false when the date is cleared, the function returns and the event never gets cleared. Looking at quick fix by @shaan1974 , I think the issue could actually be fixed by simply moving a parenthesis! My fix (without needing to update the source) is below. Notice the placement of the parentheses when compared to original.

jQuery.fn.datetimepicker.Constructor.prototype._notifyEvent = function _notifyEvent(e) {
	if (e.type === jQuery.fn.datetimepicker.Constructor.Event.CHANGE && (e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate))
	{
		return;
	}
	this._element.trigger(e);
};

This solution (@lesilent ) worked very well without the necessity to modify the source code. Thank you !

@takinola
Copy link

@lesilent I may be doing something wrong but when I insert this code, I get an error "err: TypeError: Cannot read property 'Constructor' of undefined". Any thoughts on why this isn't working for me?

@lesilent
Copy link

@lesilent I may be doing something wrong but when I insert this code, I get an error "err: TypeError: Cannot read property 'Constructor' of undefined". Any thoughts on why this isn't working for me?

@takinola It sounds like your code didn't load the tempusdominus.js isn't properly prior to executing the code fix. Make sure that it's loaded properly. If you're still having issues, then try reproducing the issue in a jsfiddle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests