Love Sharma
Love Sharma

Reputation: 1999

Which event fires when i click outside paper-dialog?

I want to catch dismiss event of paper-dialog box.

Is there any event which fires on tab out / outside dialog box?

Upvotes: 1

Views: 2099

Answers (3)

kashmoneymillionaire
kashmoneymillionaire

Reputation: 75

As of the Polymer 1.0 release, you can do the following:

<paper-dialog id="loginDialog">
    ...
</paper-dialog>

var dialog = document.getElementById('loginDialog');
dialog.addEventListener('iron-overlay-closed', function (customEvent) {
    var id = customEvent.currentTarget.id;
    console.log(id + " is closed!");
});

The customEvent has many different properties that allow you to see which dialog you are coming from. The example above looks at the Id of the currentTarget field.

In the paper-dialog-behaviors.html we see that the following events can be listened to:

listeners: {
  'click': '_onDialogClick',
  'iron-overlay-opened': '_onIronOverlayOpened',
  'iron-overlay-closed': '_onIronOverlayClosed'
},

Upvotes: 2

Justin XL
Justin XL

Reputation: 39006

You can try core-overlay-close-completed.

Please see this jsbin.

Upvotes: 1

Love Sharma
Love Sharma

Reputation: 1999

I tried another (after suggested by @justin) approach to get triggered:

  observe: {
    '$.dialog.opened': 'dialogChanged'
  },
  dialogChanged: function (old, new) {
    console.log(new);
  },

I see, opened attribute with dialog and it changed depending on dialog status.

Upvotes: 1

Related Questions