I'm using the fantastic knockout.js to bind ViewModel properties to the DOM. Now, part of my GUI is rendered on a canvas element. I use fabric.js to draw the elements on the canvas. Since these elements are not part of the dom (they are wrappers around canvas drawing methods), I cannot use knockout to bind to them. Nevertheless, I need to keep track of their position/color/label in the ViewModel.

I would think I could create a custom binding for each of the fabric primitive types and then bind them just like a dom node. However, a custom binding expects a DOM element as its first parameter. Secondly, I cannot (easily) add a binding programmatically. I need to be able to do this since I can't write the bindings in HTML.

I'm still thinking about this but I'm kinda stuck for the moment. Any ideas?