Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
[fix] set timeout to invoke callback function after the model is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy92 committed May 26, 2014
1 parent 11d0358 commit f472c4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions build/angular-date-range-picker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/angular-date-range-picker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/angular-date-range-picker.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module "dateRangePicker", ['pasvaz.bindonce']

angular.module("dateRangePicker").directive "dateRangePicker", ["$compile", ($compile) ->
angular.module("dateRangePicker").directive "dateRangePicker", ["$compile", "$timeout", ($compile, $timeout) ->
# constants
pickerTemplate = """
<div ng-show="visible" class="angular-date-range-picker__picker" ng-click="handlePickerClick($event)" ng-class="{'angular-date-range-picker--ranged': showRanged }">
Expand Down Expand Up @@ -208,7 +208,7 @@ angular.module("dateRangePicker").directive "dateRangePicker", ["$compile", ($co
$scope.ok = ($event) ->
$event?.stopPropagation?()
$scope.model = $scope.selection
$scope.callback() if $scope.callback
$timeout -> $scope.callback() if $scope.callback
$scope.hide()

$scope.select = (day, $event) ->
Expand Down
6 changes: 3 additions & 3 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
$scope.range2 = moment().range("2012-11-15", "2012-12-25")
}

$scope.fireCallback = function() {
console.log('callback fired!');
$scope.fireCallback = function(range) {
console.log(range);
};

$scope.date = null
Expand All @@ -37,7 +37,7 @@
<h1>Date range picker</h1>
<date-range-picker ng-model="range"></date-range-picker>
<pre>{{ range.start.toDate() }} - {{ range.end.toDate() }}</pre>
<date-range-picker ng-model="range2" ranged="true" callback="fireCallback()"></date-range-picker>
<date-range-picker ng-model="range2" ranged="true" callback="fireCallback(range2)"></date-range-picker>
<button ng-click="change()">Change</button>
</div>
<div>
Expand Down

0 comments on commit f472c4f

Please sign in to comment.