{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/6224","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/6224/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/6224/comments","events_url":"https://api.github.com/repos/angular/angular/issues/6224/events","html_url":"https://github.com/angular/angular/issues/6224","id":124613484,"number":6224,"title":"jquery losing their context","user":{"login":"gustavolira","id":1463004,"avatar_url":"https://avatars.githubusercontent.com/u/1463004?v=3","gravatar_id":"","url":"https://api.github.com/users/gustavolira","html_url":"https://github.com/gustavolira","followers_url":"https://api.github.com/users/gustavolira/followers","following_url":"https://api.github.com/users/gustavolira/following{/other_user}","gists_url":"https://api.github.com/users/gustavolira/gists{/gist_id}","starred_url":"https://api.github.com/users/gustavolira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gustavolira/subscriptions","organizations_url":"https://api.github.com/users/gustavolira/orgs","repos_url":"https://api.github.com/users/gustavolira/repos","events_url":"https://api.github.com/users/gustavolira/events{/privacy}","received_events_url":"https://api.github.com/users/gustavolira/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-01-02T21:59:49Z","updated_at":"2016-08-06T09:34:43Z","closed_at":"2016-08-06T09:34:43Z","body":"Hi,\r\nI'm using Angular 2 beta with typescript.\r\nJquery is losing their context when using directives, I will explain above.\r\n\r\nIf I use my html directly at page (without directive) jquery works well, but If I put this html on a directive and them use it at page using the selector jquery does not works well.\r\n\r\nFor example:\r\n\r\nIf I put this piece of html directly on a page:\r\n\r\n```HTML\r\n...\r\n<nav>\r\n    <ul>\r\n      <li class=\"active\">\r\n        <a href=\"index.html\" title=\"Dashboard\"><i class=\"fa fa-lg fa-fw fa-home\"></i> <span class=\"menu-item-parent\">Dashboard</span></a>\r\n      </li>\r\n      <li>\r\n        <a href=\"inbox.html\"><i class=\"fa fa-lg fa-fw fa-inbox\"></i> <span class=\"menu-item-parent\">Inbox</span><span class=\"badge pull-right inbox-badge\">14</span></a>\r\n      </li>\r\n...\r\n```\r\nAnd use my js like:\r\n\r\n```javascript\r\n$.fn.extend({\r\n  jarvismenu : function(options) {\r\n     console.log($(this))\r\n  }\r\n})\r\n```\r\nthis print to me \r\n```javascript\r\nObject[ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul, ul]\r\n```\r\n\r\nBut if I use a component like:\r\n```typescript\r\n@Component({\r\n  selector: 'menu'\r\n})\r\n\r\n@View({\r\n  templateUrl: './components/app/menu.html'\r\n})\r\n\r\nexport class Menu {}\r\n```\r\n```javascript console.log($(this)) ``` will print  ```javascript Object[] ```\r\n\r\nSorry If I was not so clear\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/238015047","html_url":"https://github.com/angular/angular/issues/6224#issuecomment-238015047","issue_url":"https://api.github.com/repos/angular/angular/issues/6224","id":238015047,"user":{"login":"pkozlowski-opensource","id":973550,"avatar_url":"https://avatars.githubusercontent.com/u/973550?v=3","gravatar_id":"","url":"https://api.github.com/users/pkozlowski-opensource","html_url":"https://github.com/pkozlowski-opensource","followers_url":"https://api.github.com/users/pkozlowski-opensource/followers","following_url":"https://api.github.com/users/pkozlowski-opensource/following{/other_user}","gists_url":"https://api.github.com/users/pkozlowski-opensource/gists{/gist_id}","starred_url":"https://api.github.com/users/pkozlowski-opensource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkozlowski-opensource/subscriptions","organizations_url":"https://api.github.com/users/pkozlowski-opensource/orgs","repos_url":"https://api.github.com/users/pkozlowski-opensource/repos","events_url":"https://api.github.com/users/pkozlowski-opensource/events{/privacy}","received_events_url":"https://api.github.com/users/pkozlowski-opensource/received_events","type":"User","site_admin":false},"created_at":"2016-08-06T09:34:43Z","updated_at":"2016-08-06T09:34:43Z","body":"So you are trying to use jQuery with Angular 2 in the way that is super-tricky to get right and not really recommended. The issue is that both jQuery and Angular2 are \"competing\" over DOM generation and you will get wired results depending on timing of DOM generation."}}
{"actor":{"display_login":"pkozlowski-opensource"}}