Unobtrusive knockout without pollution at home

Are there any “unobtrusive knockouts” that don't return an attribute to bind data to elements in dom? I tried several of these: http://userinexperience.com/?p=633 and the jQuery plugin.

The problem with all of them is that they continue to enter data binding back into dom. Is there something else plugin that can do something else line by line by linking the data binding in the extension, for example http://docs.jquery.com/Data

+6
source share
3 answers

Knockout. The unobtrusive plugin was my initial attempt to move away from the data-bind attributes, and back when I created it, adding model anchor elements back to the DOM was the only sensible way I could do this.

As Ryan notes, Knockout 2.0 allows you to create your own binding providers that replace the data-bind attributes with your preferred strategy. Thus, I am currently updating my plugin to provide one of these providers, which will eliminate any entry in the DOM at runtime. You can check your progress in the ko-v2 branch here . Let me know if you have any comments or suggestions. And be careful, I'm just getting started, so nothing works yet, but I have to have another fixator or two to share the next day or so.


2-28-12 Update

I have added additional tests and functionality to the branch above. The current functionality is basic, but still meets your data binding bypass requirements.

Let me know what you think. This can be allocated to a new project (with Knockout.Unobtrusive disabled)

+5
source

Here's an article that shows how to create your own binding provider: http://www.knockmeout.net/2011/09/ko-13-preview-part-2-custom-binding.html .

It would be easy to create a binding provider that saves / loads its data from jQuery $ .data or as the expando property (can use ko.utils.domData.get / set).

The binding provider just needs to implement the functions nodeHasBindings and getBindings .

If you need further help implementing something like this, let me know.

+3
source

Sorry for resuming the old question, but I was looking for something like this and could not find something flexible enough for our needs. Only about 30 minutes to write your own is what I came up with.

+1
source

Source: https://habr.com/ru/post/909001/


All Articles