0
votes

How can we implement this feature in Polymer?

confirmation example

(example from github wiki page editing)

I suppose we have an application based on the Polymer Starter Kit (so with page.js as router engine)

  • my application uses a product-editor element which contains a textarea + a save button.
  • User is editing a product at the route localhost/#!/product/127/edit
  • He "accidentally" clicks on the Back button or other links on the page

I'd like to display the above confirmation dialog: "Are you sure to leave..."

How can we do this?

1
You could try hook into the window.onbeforeunload handler and use an element like paper-dialog.miqh
I don't think the window.onbeforeunload will triggered in a SPAHiep

1 Answers

0
votes

You can use page.exit("/product/:id/edit", function(next){ }); and handle in this callback the action you want to perform: display a popup for user.