simplesystems
simplesystems

Reputation: 859

Polymer paper-tabs before tab-change (beforeunload)

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.

Upvotes: 1

Views: 192

Answers (1)

tony19
tony19

Reputation: 138696

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

Upvotes: 1

Related Questions