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

Init date in show method #726

Closed
guilhermeaiolfi opened this issue Jan 8, 2015 · 10 comments
Closed

Init date in show method #726

guilhermeaiolfi opened this issue Jan 8, 2015 · 10 comments
Milestone

Comments

@guilhermeaiolfi
Copy link
Contributor

Hi,

First of all: great lib. Congrats.

So, I was trying to use it in a new project I'm working on that uses ractive.js (but the problem should show up in ember.js, angular, etc as well). The initialization process starts before the databinding process sets the value in the input tag. So it(bootstrap-datetimepicker) thinks there's no date set in the input and use the current date.

To workaround this problem I suggest bring this code:

                    if (input.val().trim().length !== 0) {
                        setValue(parseInputDate(input.val().trim()));
                    } else if (options.defaultDate) {
                        setValue(options.defaultDate);
                    }

to the show method. So it will consider the value in the input by the time it is going to show the modal window.

Edit: I'm using v4beta

Eonasdan added a commit that referenced this issue Jan 18, 2015
@Eonasdan
Copy link
Owner

I had a fix in place for you but the jasmine test failed. I'll have to look into it more, sorry.

Eonasdan added a commit that referenced this issue Feb 3, 2015
Added temp fix for #740
Fixed: #726, #694
I think I fixed: #716
Features:
Added several key bindings from #693
Fully implemented inline mode! #381, #752, #692, #84
Added clear public function

had to revert namespace changes :(
@Eonasdan
Copy link
Owner

Eonasdan commented Feb 3, 2015

@guilhermeaiolfi check out the dev branch and let me know if that worked for you

@Eonasdan Eonasdan added fixed and removed v4 labels Feb 3, 2015
@Eonasdan Eonasdan added this to the 4.3 milestone Feb 3, 2015
@guilhermeaiolfi
Copy link
Contributor Author

Hi,

sorry the delay. I was on vacation. So, I tested the 4.0.0 release and the development branch. None worked for me.

Looking at a4e7201 I don't see what change would fix what I described.

@guilhermeaiolfi
Copy link
Contributor Author

In the show function, if I create a else for this condition: https://github.com/Eonasdan/bootstrap-datetimepicker/blob/d072d926998f6277b555d74d35b78e8b81cb8762/src/js/bootstrap-datetimepicker.js#L991

like so:

  if (options.useCurrent && unset && (input.is('input') && input.val().trim().length === 0)) {
    ...
  } else {
   setValue(parseInputDate(input.val().trim()));
  }

It works. I don't see how to solve the problem I'm describing without the above line somewhere in the show function. Since it is what will set the lazy value as date.

@guilhermeaiolfi
Copy link
Contributor Author

@Eonasdan could you reopen this issue?

@Eonasdan Eonasdan reopened this Mar 21, 2015
@Eonasdan
Copy link
Owner

can you setup a fiddle or a demo page for this please?

@guilhermeaiolfi
Copy link
Contributor Author

Sure, I should have done that from the start: https://jsfiddle.net/UG7Eq/13/

@Eonasdan
Copy link
Owner

Eonasdan commented Apr 2, 2015

the fiddle you posted seems to work just fine for me. What I am looking for? Sorry :)

@guilhermeaiolfi
Copy link
Contributor Author

The date set in the model (then propagate to the input element) is not the
date shown in the widget when opened.
Em 02/04/2015 17:31, "Eonasdan" [email protected] escreveu:

the fiddle you posted seems to work just fine for me. What I am looking
for? Sorry :)


Reply to this email directly or view it on GitHub
#726 (comment)
.

@guilhermeaiolfi
Copy link
Contributor Author

Were you able to see the problem in the fiddle?

@ghost ghost locked and limited conversation to collaborators Jun 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants