{"action":"created","issue":{"url":"https://api.github.com/repos/likeastore/ngDialog/issues/179","labels_url":"https://api.github.com/repos/likeastore/ngDialog/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/likeastore/ngDialog/issues/179/comments","events_url":"https://api.github.com/repos/likeastore/ngDialog/issues/179/events","html_url":"https://github.com/likeastore/ngDialog/issues/179","id":59788184,"number":179,"title":"$escape notification is not propagated correctly","user":{"login":"DorianGrey","id":1473055,"avatar_url":"https://avatars.githubusercontent.com/u/1473055?v=3","gravatar_id":"","url":"https://api.github.com/users/DorianGrey","html_url":"https://github.com/DorianGrey","followers_url":"https://api.github.com/users/DorianGrey/followers","following_url":"https://api.github.com/users/DorianGrey/following{/other_user}","gists_url":"https://api.github.com/users/DorianGrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DorianGrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DorianGrey/subscriptions","organizations_url":"https://api.github.com/users/DorianGrey/orgs","repos_url":"https://api.github.com/users/DorianGrey/repos","events_url":"https://api.github.com/users/DorianGrey/events{/privacy}","received_events_url":"https://api.github.com/users/DorianGrey/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/likeastore/ngDialog/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/likeastore/ngDialog/labels/pull%20request%20welcome","name":"pull request welcome","color":"bfe5bf"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-04T11:57:35Z","updated_at":"2015-10-08T09:15:30Z","closed_at":"2015-10-08T09:15:29Z","body":"My team recently faced an issue regarding the propagation of '$escape' as value-parameter of the object handled over to a dialog's closePromise.\r\n\r\nAfter a small debugging round, we've that publicMethods.close is only called with '$escape' as parameter, but it awaits an id as the first parameter. \r\n```\r\nclose: function (id, value) {\r\n  var $dialog = $el(document.getElementById(id));\r\n  if ($dialog.length) {\r\n    privateMethods.closeDialog($dialog, value);\r\n  } else {\r\n    publicMethods.closeAll(value);\r\n  }\r\n  return publicMethods;\r\n}\r\n```\r\nAs a result, the value parameter of this function is undefined, which is propagated.\r\nThe cause of this issue seems to be that the onDocumentKeydown function does not have access to the dialog's id. This makes sense somehow, since it's a general function - however, to propagate the signal correctly, it required access to it.\r\nWe've fixed this (temporarily) by binding $dialog to the function that is registered to the keydown event.\r\n```\r\n--- public/lib/ngDialog/js/ngDialog.js  (date 1425456746000)\r\n+++ public/lib/ngDialog/js/ngDialog.js  (revision )\r\n@@ -62,9 +62,9 @@\r\n         }\r\n \r\n         var privateMethods = {\r\n-          onDocumentKeydown: function (event) {\r\n+          onDocumentKeydown: function ($dialog, event) {\r\n             if (event.keyCode === 27) {\r\n-              publicMethods.close('$escape');\r\n+              publicMethods.close($dialog.attr('id'), '$escape');\r\n             }\r\n           },\r\n \r\n@@ -278,7 +278,7 @@\r\n               });\r\n \r\n               if (options.closeByEscape) {\r\n-                $body.bind('keydown', privateMethods.onDocumentKeydown);\r\n+                $body.bind('keydown', privateMethods.onDocumentKeydown.bind(this, $dialog));\r\n               }\r\n \r\n               if (options.closeByNavigation) {\r\n```\r\nNote that only binding the dialog's id should also be sufficient in most cases. "},"comment":{"url":"https://api.github.com/repos/likeastore/ngDialog/issues/comments/146467111","html_url":"https://github.com/likeastore/ngDialog/issues/179#issuecomment-146467111","issue_url":"https://api.github.com/repos/likeastore/ngDialog/issues/179","id":146467111,"user":{"login":"DorianGrey","id":1473055,"avatar_url":"https://avatars.githubusercontent.com/u/1473055?v=3","gravatar_id":"","url":"https://api.github.com/users/DorianGrey","html_url":"https://github.com/DorianGrey","followers_url":"https://api.github.com/users/DorianGrey/followers","following_url":"https://api.github.com/users/DorianGrey/following{/other_user}","gists_url":"https://api.github.com/users/DorianGrey/gists{/gist_id}","starred_url":"https://api.github.com/users/DorianGrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DorianGrey/subscriptions","organizations_url":"https://api.github.com/users/DorianGrey/orgs","repos_url":"https://api.github.com/users/DorianGrey/repos","events_url":"https://api.github.com/users/DorianGrey/events{/privacy}","received_events_url":"https://api.github.com/users/DorianGrey/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T09:15:29Z","updated_at":"2015-10-08T09:15:29Z","body":"Sorry for the delay ... I've re-tested this issue against 0.5.5, and it works fine. \r\n\r\nI've taken a look at the source - you've rewritten publicMethos.close in a way that selects the corresponding dialog, which was not present in the version that this issue refers to.\r\n\r\nI.e. - issue is fixed."}}