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

Set time by JavaScript #6

Closed
Erando89 opened this issue Dec 13, 2017 · 6 comments
Closed

Set time by JavaScript #6

Erando89 opened this issue Dec 13, 2017 · 6 comments

Comments

@Erando89
Copy link

Hi Andy,

now I need to set the time using JavaScript. Therefore I've written these two lines of code:

$input.val("08:00");
$input.parent().find('canvas:first').trigger('mousemove'); // repaints canvas

As you can see I am setting the time of the input field and then try to repaint your canvas by triggering the mousemove event. This works fine on desktops and tablets but fails on smartphones (e.g. Android 6.0.1 Chrome 63.0). I guess there's no such thing as mouse events on smartphones. So a function to repaint/refresh your timepicker would be of great help.

Thanks for your awesome timepicker though!

Best regards

Andi

@loebi-ch
Copy link
Owner

Hi Andi

Thank you for your precious input.

Please update to version 2.1.4 and use the following code to change the input's value at runtime:

$input.clockTimePicker('value', '08:00');

Cheers, Andy

@Erando89
Copy link
Author

Thank you Andy. It works just like my approach even though it's a lot handier und prettier than mine.
The problem on mobile devices remains though. As you can see in my screenshot the time doesn't get selected properly.

photo_2017-12-13_15-10-05

Do you think you could provide a solution which works on mobile devices as well?

@loebi-ch
Copy link
Owner

I tested on my mobile phone and it works like a charm... hmmm... I think you have cleared your browser cache on your mobile phone?!
Can you provide me with a test URL to see you problem in action?

@Erando89
Copy link
Author

Alright: http://ramm-stein.de/test.html.

Deleting all data of my browser didn't do the trick.

@loebi-ch
Copy link
Owner

Alright, thank you for the link. I could reproduce your issue and I could find the problem and a possible solution.

This click event is not fired on the mobile phone (don't ask me why?!?):

$('.clockTime').on('click', setDefaultTimeValue);

An alternative to call your callback function is to use the onOpen event:

var clockTimePickerOptions = {
	precision: 15,
	i18n: {
		cancelButton: 'Abbrechen',
		okButton: 'OK'
	},
	onOpen: setDefaultTimeValue
};

@Erando89
Copy link
Author

Damn it, that's been the problem. Thank you so much!

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

2 participants