angular-datepicker icon indicating copy to clipboard operation
angular-datepicker copied to clipboard

Autoclose

Open Opa- opened this issue 12 years ago • 8 comments

Autoclose of the datepicker when selecting a value on the min-view would be very appreciated :+1:

Opa- avatar Nov 26 '14 11:11 Opa-

I modified the dist/index.js so that when the data is entered into the model (ie: on the final view), the popup closes (using Jquery): Here's my diff:

--- client/js/index.js  2014-12-06 11:41:27.000000000 +1300
+++ /Users/nick/Downloads/angular-datepicker-master/dist/index.js       2014-11-25 03:59:18.000000000 +1300
@@ -215,12 +215,10 @@
             scope.model.setFullYear(date.getFullYear());
           }
           scope.$emit('setDate', scope.model, scope.view);
-        } 
+        }

         if (nextView) {
           scope.setView(nextView);
-        } else {              
-          $('.dropdown-toggle').parent().removeClass('open'); // Nick: This is where we should close the popup
         }
       };

NickLarsenNZ avatar Dec 05 '14 22:12 NickLarsenNZ

+1 to that.

dnlmzw avatar Jan 29 '15 14:01 dnlmzw

Alternatively to:

$('.dropdown-toggle').parent().removeClass('open');

If you don't want to point to a specific element, you can replace it with:

setTimeout(function(){ scope.$emit('$destroy'); }, 1);

Or (only when used with input fields):

$(':focus').blur();

dnlmzw avatar Jan 29 '15 14:01 dnlmzw

I think this should be optional, like a flag on the date-picker directive like "<... auto-close='true' />"

eralha avatar Feb 11 '15 11:02 eralha

I agree with @eralha. In mine opinion that's a big +1

Any plans for implementing that

pkalkman avatar Mar 04 '15 14:03 pkalkman

I can implement that, i just need to give it a little more thinking, because you can manage the visibility of the datepicker with so many things for exp: ng-class, ng-visible etc... i need to see if the implementation doesn´t clash with any functionality

eralha avatar Mar 04 '15 14:03 eralha

Yes, please add :+1:

patricktargun avatar Mar 04 '15 19:03 patricktargun

Closed, you can set the attribute auto-close="true" to use this feature.

eralha avatar Mar 09 '15 17:03 eralha