-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should be able to unapply bindings #724
Comments
Your example will not work if the "widget" contains control-flow bindings. It will "unbind" okay, but the resulting html may not be the same as the original. Knockout already has the |
I've never tried to "rebind" the html after "unbinding" because I always remove the html. |
I've mocked up a quick example of how I'm using the method in combination with Ryan Niemeyer's ClassBindingProvider here: http://jsfiddle.net/mberkom/genXq/13/ |
Creating a way of removing bindings would be quite a significant change - it would mean that all existing bindings (including custom bindings) would need some extra callback function (e.g., All that said, I can appreciate it would permit extra flexibility in some cases. I'll keep this issue report open as a possible future enhancement.
Sorry, I didn't really follow what you were doing here or how it differs from usual patterns. Could you clarify? |
Yes, I can. Following the concept of large scale JS application architecture found here, I created an object I call the Knockout Module. It's a viewmodel wrapped with By declaring a viewmodel with my Knockout Module pattern, it is now possible to insert an editing interface anywhere without requiring it to be nested beneath another viewmodel's bindings. See my question here for a possible application. I'm currently using it for loading a form to edit table rows. |
Hi Steve, First, thanks for an awesome library. We definitely need an uninit callback in bindings. I'm building a rich application where widgets are often created and destroyed (each widget is like a page, with ko bound data), so I need a way to clean up to avoid mem leaks. Thanks! |
+1 For a solution of mem leaks. Doesn't have to be a complicated unbind, or even reverting back to the state before binding. Just need a way to dispose things no longer needed. |
+1 for this. I have situation where we have to pre-render the DOM elements to prevent locking up IE7/8. mberkom's function is a big help. |
FYI, Mberkom's unapplybindings script is also excellent at reducing IE7 memory leaks. I added it to my page.unload and it helped a good bit. |
My concern for this mostly lies with clashes between KO and other frameworks - namely Backbone or jQuery. Having Simply put - using jQuery's |
This appears to be very similar to issue #41. |
Closing. Conversation can continue in #41. |
Knockout should have a complete method for unapplying bindings. I've written my own that seems to work fairly well and would like to see something similar integrated into the core.
This is especially useful when setting up a Knockout viewmodel as a widget which can be added and removed dynamically.
The text was updated successfully, but these errors were encountered: