bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Dynamic list of tabsets in 0.5.0

Open davidmdem opened this issue 13 years ago • 25 comments

Repeating a dynamic list of tabsets breaks in 0.5.0 while working as expected in 0.4.0.

0.4.0 - Working: http://plnkr.co/edit/tPVbfa9lI1CarrDS171p?p=preview

0.5.0 - "Cannot read property '$parent' of undefined" http://plnkr.co/edit/er6lg52FYHn4AyRF5kSm?p=preview

davidmdem avatar Aug 07 '13 14:08 davidmdem

a error happens if add active property on the tab to:

http://plnkr.co/edit/kAc1C6?p=preview

TypeError: undefined is not a function
    at Object.fn (http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.5.0/ui-bootstrap-tpls.min.js:1:31943)
    at Object.Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:8811:27)
    at Object.Scope.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:9012:24)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:1004:15
    at Object.invoke (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:2925:25)
    at resumeBootstrapInternal (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:1002:14)
    at bootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:1017:12)
    at angularInit (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:977:5)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:16872:5
    at HTMLDocument.trigger (https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js:1812:7) 

dtelaroli avatar Aug 09 '13 03:08 dtelaroli

Appears to a be an issue with https://github.com/angular-ui/bootstrap/blob/master/src/tabs/tabs.js#L307:

tabsetCtrl.$transcludeFn(tabsetCtrl.$scope.$parent, function(node) {.

The problem appears to be that tabsetCtrl.$scope is set in the compile phase of tabset. Which means, tabsets can no longer be generated dynamically (because the compile phase happens once). Is this intended to be a supported feature @ajoslin?

EDIT: The above is based on the assumption that ng-repeat doesn't recompile every time it watches an object for changes. If ng-repeat is simpy cloning and adding an index hash to each object iteration, then it won't recompile, which means the tabset compile stage gets skipped.

hallister avatar Aug 10 '13 20:08 hallister

Ergh, sorry. I should have looked at tabsetTitles better bfeore merging it, it kind of was rushed in.

ajoslin avatar Aug 12 '13 03:08 ajoslin

Hmm.. that is in the linking function. I don't think that line specifically is the problem. Looking into this now

ajoslin avatar Aug 12 '13 03:08 ajoslin

@dtelaroli your error is happening because '!active' is not an assignable expression. When we upgrade to angular 1.2 we will get better errors for that.

ajoslin avatar Aug 12 '13 03:08 ajoslin

http://plnkr.co/edit/lw1PS6rpe7xXNfZXN3xR?p=preview

With the ng-repeat, the tabset-titles is compiled before the tabset for some reason.

I added a setTimeout and it works - check line 2676 of ui-bootstrap.js on the plunker.

To actually fix it, I will have to try a few more things .. another day

ajoslin avatar Aug 12 '13 03:08 ajoslin

thanks @ajoslin

dtelaroli avatar Aug 12 '13 12:08 dtelaroli

thanks @ajoslin for the temporary solution. I really appreciatee it!

karol-f avatar Aug 26 '13 22:08 karol-f

Yes - thank you for the temporary solution.. However, the solution results in the tabs being underneath the content (your plnkr example shows the problem). Any update on the fix or is there another fix to get the tabs above the content? Thanks!

npgauth avatar Aug 27 '13 23:08 npgauth

I've experienced this same error with non-dynamic nested tabs as well, reverting to 0.4.0 fixes. Plunkr. Edit: woops! Dupe of https://github.com/angular-ui/bootstrap/issues/856

lefnire avatar Aug 30 '13 02:08 lefnire

here is a small css hack to use with this one : https://github.com/angular-ui/bootstrap/issues/783#issuecomment-22471994

it's putting back the tabs above the content.

.tabbable {
    position: relative;
    padding-top: 40px; /* height of the tabs */
}

.tabbable .nav-tabs {
    position: absolute;
    top: 0;
}

ghost avatar Sep 03 '13 14:09 ghost

Could this be related to https://github.com/angular/angular.js/issues/2064?

derekrprice avatar Sep 08 '13 21:09 derekrprice

same problem here, but it worked great in development untill i did precompile on production and saw this error

amfern avatar Sep 23 '13 08:09 amfern

Hi @ajoslin Have you think about a definitive solution of this matter? I have tried your solution but the tabs now are underneath the content and even if i tried the @desgnl css hack, it is not working for me anymore.. I would like to have again the version 0.4.0 but unfortunately that version does not fit anymore in other requirements in my project.

abottoni avatar Oct 01 '13 13:10 abottoni

@ajoslin do you have a reference to a bug in AngularJS that might be the root cause of this one? If so I could try to "lobby" for its faster resolution. I'm looking at the issue right now but I'm totally puzzled by what is going on, as I fail to understand why the linking function of the nested tabset is not executed....

pkozlowski-opensource avatar Oct 01 '13 13:10 pkozlowski-opensource

It is because templateUrl directives are evaluated asynchronously and in a different order, so a timeout fixes the asynchronous problem of directives not loading in time. I can find the issue later, it is the one where vojta posted a PR for $compile recently ... It may be merged already. 

— Sent from Mailbox for iPhone

On Tue, Oct 1, 2013 at 9:54 AM, Pawel Kozlowski [email protected] wrote:

@ajoslin do you have a reference to a bug in AngularJS that might be the root cause of this one? If so I could try to "lobby" for its faster resolution. I'm looking at the issue right now but I'm totally puzzled by what is going on, as I fail to understand why the linking function of the nested tabset is not executed....

Reply to this email directly or view it on GitHub: https://github.com/angular-ui/bootstrap/issues/783#issuecomment-25450950

ajoslin avatar Oct 01 '13 14:10 ajoslin

What's the solution for this? We need tabs in our application and this is really throwing a wrench in the gears.

mboudreau avatar Oct 06 '13 23:10 mboudreau

we're just using bootstrap proper for things that don't work in ui-bootstrap, like this issue. mix-n-match

lefnire avatar Oct 06 '13 23:10 lefnire

The problem here is that our app is fully angular and we don't want to use jquery on top of it all. Plus, this isn't a solution or an excuse as to why it doesn't work.

On Mon, Oct 7, 2013 at 10:58 AM, Tyler Renelle [email protected]:

we're just using bootstrap proper for things that don't work in ui-bootstrap, like this issue. mix-n-match

— Reply to this email directly or view it on GitHubhttps://github.com/angular-ui/bootstrap/issues/783#issuecomment-25779862 .

"If at first you don't succeed, use a bigger hammer." - Unofficial motto of the Royal Electrical and Mechanical Engineers

mboudreau avatar Oct 07 '13 00:10 mboudreau

It looks like it will be fixed in 1.2.0: https://github.com/angular/angular.js/pull/3927

ajoslin avatar Oct 07 '13 02:10 ajoslin