Skip to content

Commit

Permalink
Merge pull request #131 from charleshimmer/master
Browse files Browse the repository at this point in the history
Fixing bug with tabs inside a modal.
  • Loading branch information
erik-krogh committed Mar 2, 2016
2 parents c32cd72 + cf2eb5a commit b7da0da
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/angular-materialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,30 +844,39 @@
outDuration: "@",
ready: '&?',
complete: '&?',
open: '='
open: '=',
enableTabs: '@?'
},
link: function (scope, element, attrs) {
$timeout(function () {
var modalEl = $(attrs.href ? attrs.href : '#' + attrs.target);
$compile(element.contents())(scope);

var complete = function () {
angular.isDefined(scope.complete) && scope.$eval(scope.complete());
angular.isFunction(scope.complete) && scope.$eval(scope.complete());

scope.open = false;
scope.$apply();
};

var ready = function() {
angular.isFunction(scope.ready) && scope.$eval(scope.ready());
// If tab support is enabled we need to re-init the tabs
// See https://github.com/Dogfalo/materialize/issues/1634
if (scope.enableTabs) {
modalEl.find('ul.tabs').tabs();
}
};
var options = {
dismissible: (angular.isDefined(scope.dismissible)) ? scope.dismissible : undefined,
opacity: (angular.isDefined(scope.opacity)) ? scope.opacity : undefined,
in_duration: (angular.isDefined(scope.inDuration)) ? scope.inDuration : undefined,
out_duration: (angular.isDefined(scope.outDuration)) ? scope.outDuration : undefined,
ready: (angular.isDefined(scope.ready)) ? function() {scope.$eval(scope.ready())} : undefined,
ready: ready,
complete: complete,
};
element.leanModal(options);

// Setup watch for opening / closing modal programatically.
if (angular.isDefined(attrs.open) && modalEl.length > 0) {
scope.$watch('open', function(value, lastValue) {
if (!angular.isDefined(value)) { return; }
Expand Down

0 comments on commit b7da0da

Please sign in to comment.