Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

uib-tab settings: click() #5716

Closed
yasinkocak opened this issue Mar 31, 2016 · 6 comments
Closed

uib-tab settings: click() #5716

yasinkocak opened this issue Mar 31, 2016 · 6 comments

Comments

@yasinkocak
Copy link

I want to have a uib-tab setting click() that called an optional expression without change the tabcontent.

There is already select() but this changes tab content.

@icfantv
Copy link
Contributor

icfantv commented Mar 31, 2016

I think what you may want is a way to call event.preventDefault to keep the tab from changing. Would this work?

Currently this feature does not exist in the library but has been requested before and is certainly worth a conversation.

@yasinkocak
Copy link
Author

I have a table on activated tab 1

And i want a tabset that changes my records at the table when it's clicked without changing the tab.

If i use select() this change also the tab

@icfantv
Copy link
Contributor

icfantv commented Mar 31, 2016

Sorry, you want your table to change when what is clicked?

@yasinkocak
Copy link
Author

<uib-tabset>
  <uib-tab heading="table-1">
    <table>...<table>
  </uib-tab>
  <uib-tab heading="table-2">
    <table>..</table>
  </uib-table>
  <uib-tab class="pull-right" select="$ctrl.changeRecords()">
    <uib-tab-heading>Change table records</uib-tab-heading>
  </uib-tab>
</uib-tabset>

As u can see i have 3 tab.
First 2 tab have a content with table. And the last one is clickable tab without content.

When i use select() the records from the table are changed. But the tab of "table-1" is disactivated and get blanco tab content of the last tab.

I want to click on the last tab to call an expression without disabling current tab.

@wesleycho
Copy link
Contributor

One temporary way one can do this I think is using ng-click to cache the prior tab value, and use $timeout to change it after.

I think @icfantv's suggestion would work for the library itself.

@icfantv
Copy link
Contributor

icfantv commented Mar 31, 2016

In the interim, @yasinkocak, you can override the tab template and have your ng-click supercede the original one. Something like:

<li ng-class="[{active: active, disabled: disabled}, classes]" class="uib-tab nav-item">
  <a href ng-click="doSomething() && select($event)" class="nav-link" uib-tab-heading-transclude>{{heading}}</a>
</li>

And if doSomething() returns false the tabs won't change because select(...) won't be fired. I give you that this is not ideal, but until we wire in the event propagation stoppage, this should keep you moving.

To override the template, simply specify a template-url property on your tab or you can override the tab template already in the $templateCache. If you do the latter, the key you need to override is uib/template/tabs/tab.html.

I'm going to close this as a support issue but will open one to track the stoppage of the event propagation.

@icfantv icfantv closed this as completed Mar 31, 2016
icfantv added a commit to icfantv/bootstrap that referenced this issue Mar 31, 2016
* add ability for user to prevent currently selected tab's deselction by
calling `$event.preventDefault()` in tab's `deselect` callback.

Fixes angular-ui#5720
Addresses angular-ui#2715, angular-ui#4836, and angular-ui#5716.
icfantv added a commit to icfantv/bootstrap that referenced this issue Mar 31, 2016
* add ability for user to prevent currently selected tab's deselection by
calling `$event.preventDefault()` in tab's `deselect` callback.

Fixes angular-ui#5720
Addresses angular-ui#2715, angular-ui#4836, and angular-ui#5716.
icfantv added a commit that referenced this issue Mar 31, 2016
* add ability for user to prevent currently selected tab's deselection by
calling `$event.preventDefault()` in tab's `deselect` callback.

Fixes #5720
Addresses #2715, #4836, and #5716.
Closes #5723
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

3 participants