Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knockout JS with Alternate DOM Backend

Tags:

I would like to implement a different non-HTML DOM backend for Knockout JS, likely within a non-browser type of environment (likely Node.js). Specifically, there exists an old, simple, static UI framework that I'd like to wrap with a DOM and then use with Knockout. I understand that Knockout itself is at least able to operate within Node.js without a browser environment (see here for example), but I'm wondering what I need to implement to create an entirely different DOM.

  • Is it something where I can override a few DOM manipulation classes with my own implementations?
  • Is there any notion of a DOM interface?
  • Or will I likely need to do something from the ground up with an alternate ko.applyBindings, etc.?

I'm just trying to figure out if I'm mostly crazy or completely crazy with regards to the scope of work.

like image 991
J Trana Avatar asked Jul 01 '15 00:07

J Trana


1 Answers

I think you could do this by creating custom elements (http://knockoutjs.com/documentation/component-custom-elements.html) with custom bindings (http://knockoutjs.com/documentation/custom-bindings-for-virtual-elements.html) and extending binding syntax (http://knockoutjs.com/documentation/binding-preprocessing.html)

You would probably then have to create a customer element, binding and syntax for every element within your UI, I would suggest maybe creating either a json file with element info and allowing custom elements being created using the json, with the json linking to an widget containing the logic for each element.

like image 149
dops Avatar answered Sep 29 '22 10:09

dops