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

Disable broken in 3.1.1 #493

Closed
felixbuenemann opened this issue Aug 16, 2014 · 11 comments
Closed

Disable broken in 3.1.1 #493

felixbuenemann opened this issue Aug 16, 2014 · 11 comments
Milestone

Comments

@felixbuenemann
Copy link

The datepicker does not automatically disable, if an input group is used and the input is in state disabled. See the following jsfiddle: http://jsfiddle.net/wzbhcjk5/

Expected Behavior: Clicking on Input-group-addon should do nothing.

Actual Behavior: Can open datepicker and select dates.

Input without icon is not affected.

It seems this was broken before, see #132.

@nikoskalogridis
Copy link
Contributor

It's not the same issue... #132 talks about calling disable function on datetimepicker which should work. You are talking about adding this property through other ways or even having the property on html code before even initializing the datepicker component. Am I correct? or do I miss something

@felixbuenemann
Copy link
Author

There are two issues here:

  • picker.disable and picker.eanble are not using getPickerInput()
  • picker.show does not check if input is disabled

I have a 3 line fix locally and will prepare a PR shortly.

@felixbuenemann
Copy link
Author

I've also changed the jsfiddle to show that neither disabling nor enabling inputs through the api has any effect: http://jsfiddle.net/8Ldryg82/

nikoskalogridis added a commit that referenced this issue Aug 17, 2014
@nikoskalogridis
Copy link
Contributor

check on development branch. It should work as expected now

@felixbuenemann
Copy link
Author

This looks pretty much exactly like my local changes :-)

diff --git a/vendor/assets/javascripts/bootstrap-datetimepicker.js b/vendor/assets/javascripts/bootstrap-datetimepicker.js
index 91845d7..fad266c 100644
--- a/vendor/assets/javascripts/bootstrap-datetimepicker.js
+++ b/vendor/assets/javascripts/bootstrap-datetimepicker.js
@@ -1182,6 +1182,9 @@ THE SOFTWARE.
         };

         picker.show = function (e) {
+            if (getPickerInput().prop('disabled')) {
+                return;
+            }
             if (picker.options.useCurrent) {
                 if (getPickerInput().val() === '') {
                     if (picker.options.minuteStepping !== 1) {
@@ -1220,7 +1223,7 @@ THE SOFTWARE.
         };

         picker.disable = function () {
-            var input = picker.element.find('input');
+            var input = getPickerInput();
             if (input.prop('disabled')) {
                 return;
             }
@@ -1229,7 +1232,7 @@ THE SOFTWARE.
         };

         picker.enable = function () {
-            var input = picker.element.find('input');
+            var input = getPickerInput();
             if (!input.prop('disabled')) {
                 return;
             }

I'll try your version.

@nikoskalogridis
Copy link
Contributor

there was a problem in the init as well attaching event handlers even when disabled. Anyway try it and let me know if that fixes the issue.

@felixbuenemann
Copy link
Author

It's working fine now, thank you!

@nikoskalogridis nikoskalogridis self-assigned this Aug 17, 2014
@nikoskalogridis nikoskalogridis added this to the 3.1.2 milestone Aug 17, 2014
@felixbuenemann
Copy link
Author

Can I close the issue, or do you wan't to wait for the release?

@nikoskalogridis
Copy link
Contributor

Lets leave it open as I have to check on v4beta that it works as its supposed to. I 'll close it. Thanks

nikoskalogridis added a commit that referenced this issue Aug 17, 2014
@nikoskalogridis
Copy link
Contributor

ok fixed in v4beta as well

@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.
Projects
None yet
Development

No branches or pull requests

2 participants