Unbind view model from view in knockout
You can use ko.cleanNode to remove the bindings. You can apply this to specific DOM elements or higher level DOM containers (eg. the entire form). See http://jsfiddle.net/KRyXR/157/ for an example.
You can use ko.cleanNode to remove the bindings. You can apply this to specific DOM elements or higher level DOM containers (eg. the entire form). See http://jsfiddle.net/KRyXR/157/ for an example.
You have to use a named function so you can reference that specific handler when calling .unbind(), like this: function keyUpFunc(e) { if (e.keyCode == 27) { functionZzy(); } } $(document).keyup(keyUpFunc); Then later when unbinding: $(document).unbind(“keyup”, keyUpFunc);
$(window).unbind(‘scroll’); Even though the documentation says it will remove all event handlers if called with no arguments, it is worth giving a try explicitly unbinding it. Update It worked if you used single quotes? That doesn’t sound right – as far as I know, JavaScript treats single and double quotes the same (unlike some other … Read more
You can call .unbind() without parameters to do this: $(‘p’).unbind(); From the docs: In the simplest case, with no arguments, .unbind() removes all handlers attached to the elements.