{"action":"closed","issue":{"url":"https://api.github.com/repos/knockout/knockout/issues/2315","repository_url":"https://api.github.com/repos/knockout/knockout","labels_url":"https://api.github.com/repos/knockout/knockout/issues/2315/labels{/name}","comments_url":"https://api.github.com/repos/knockout/knockout/issues/2315/comments","events_url":"https://api.github.com/repos/knockout/knockout/issues/2315/events","html_url":"https://github.com/knockout/knockout/issues/2315","id":270442712,"number":2315,"title":"Knockout binding removes my jquery DOM events","user":{"login":"shadowkras","id":33266897,"avatar_url":"https://avatars2.githubusercontent.com/u/33266897?v=4","gravatar_id":"","url":"https://api.github.com/users/shadowkras","html_url":"https://github.com/shadowkras","followers_url":"https://api.github.com/users/shadowkras/followers","following_url":"https://api.github.com/users/shadowkras/following{/other_user}","gists_url":"https://api.github.com/users/shadowkras/gists{/gist_id}","starred_url":"https://api.github.com/users/shadowkras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shadowkras/subscriptions","organizations_url":"https://api.github.com/users/shadowkras/orgs","repos_url":"https://api.github.com/users/shadowkras/repos","events_url":"https://api.github.com/users/shadowkras/events{/privacy}","received_events_url":"https://api.github.com/users/shadowkras/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2017-11-01T20:32:58Z","updated_at":"2017-11-03T18:59:38Z","closed_at":"2017-11-03T18:59:38Z","author_association":"NONE","body":"I have several jquery dom events that are created on DOM load or document ready. These are mostly default behaviors that should be applied to all forms in my application. Example:\r\n\r\n ```\r\n$('input:text').focus(function ()\r\n    {\r\n        $(this).select();\r\n    });\r\n```\r\n\r\nRight before applying knockout binding, I can check my dom elements and all events are there:\r\n\r\n[before knockout binding]( https://i.stack.imgur.com/TFvtJ.png)\r\n\r\nBut when I run the applyBindings method to bind the viewmodel to my DOM, the [\"with\" binding](http://knockoutjs.com/documentation/with-binding.html) removes all events that are not related to knockout:\r\n\r\n[after knockout biding]( https://i.stack.imgur.com/NgxlB.png)\r\n\r\nI have tried overwriting the **cleanExternalData** as explained on the [documentation](http://knockoutjs.com/documentation/custom-bindings-disposal.html#overriding-the-clean-up-of-external-data) and on [this answer](https://stackoverflow.com/a/31009412/1715160). But that did not help with this, the function is replaced, but the events are still removed from the DOM when the templating is applied on the binding process.\r\n\r\nFor the record, this is not an exclusive behavior of the *with* function, but all anonymous templating functions also do that, _foreach_, _if_, _ifnot_. Using *template*, as expected, also behaves the same way. The DOM element is completely destroyed, stored as a template, then added again on my document when the condition is satisfied, but now without any jquery event handlers.\r\n\r\nHow to avoid that knockout removes the events from my DOM elements?"}}
{"actor":{"display_login":"mbest"}}