Polymer paper-tabs before tab-change (beforeunload)

193 Views Asked by At

Is there a possibility to get an Event or something, before the selected tab changes? I'm looking for something like the window Event "beforeunload", to warn the user if he has any unsaved changes.

1

There are 1 best solutions below

1
tony19 On

You can set an iron-activate event handler on <paper-tabs>, which is notified whenever the user selects a tab. The handler could cancel the tab selection by calling event.preventDefault():

<paper-tabs on-iron-activate="_onTabActivated">...

_onTabActivated(e) {
  if (conditionToCancelSelection) {
    e.preventDefault();
  }
}

demo