Ask to confirm when changing tabs in angular bootstrap


I have tabs with forms and i want ask user to confirm to discard the changes when changing tabs. My current code works

<uib-tab heading="..." index="3" deselect="main.onDeselect($event)" ... >

this.onDeselect = function($event) {
    if(...isDirty...) {         
        if($window.confirm("Do you want to discard?")) {
            ... discard (and go to new tab) ...
        } else {
            $event.preventDefault(); //stays on current tab

The problem is I want to change confirm to javascript dialog and I will get result in callback. I planed to preventDefault all and then switch manually, but I cannot figure out where to get new tab id.

Any sollution is appreciated. Even if it is easier in other tab implementations.

I use AngularJS v1.4.7, ui-bootstrap-tpls-1.3.3.min.js


You can make use of $selectedIndex and the active property for that purpose. See this Plunk

One thing to be noted here is that when we manually change the active property, it again fires the deselect event which needed to be handled. Otherwise it seems to do what you wanted.


Indeed as noted in the comments, the deselct carries the html index rather than what is passed in in the tab index property. A workaround could be in this: Another Plunk. Here I'm pulling the actual index from the html index.

And a little research indicates that this issue might as well be fixed already with 3.0 bootstrap tpl See this

I haven't seen the use of $route.params inside the route objects. What you can do though, in your vue you can dynamically load different components based on your $route.params

<component-a v-if="$route.params == 'a'"></component-a>

If you can specify the minimum ClientCustomerId length, e.g. it can never be less than four characters, you can limit the results thus:

WHERE ClientCustomerId like left('SoseJost75G', 4) + '%'

Here an index can be used to get the matching records. Your criteria

AND ClientCustomerId <= 'SoseJost75G' and ClientCustomerId

would then have to be looked up only in the records already found.

The complete query:

SELECT CustomerId
FROM Customer cust
WHERE ClientCustomerId like left('SoseJost75G', 4) + '%'
AND ClientCustomerId <= 'SoseJost75G' and ClientCustomerId;

BTW: Your criteria can also be written as

ClientCustomerId = left('SoseJost75G', length(ClientCustomerId))

but I suppose that this isn't faster than your version.

This video can help you solving your question :)
By: admin