Knockout JS “uniqueName” binding - Same name to two fields

前端 未结 4 1076
遇见更好的自我
遇见更好的自我 2021-01-14 09:31

I am using Knockout JS to create an editor. I am using the foreach property to loop around a list in my model.

 

        
4条回答
  •  青春惊慌失措
    2021-01-14 09:42

    I wanted to post as a comment, but my reputation is too low... Thank you very much RP Niemeyer for your post.

    I don't know if this has something to do with requirejs and knockout modules, but I had to change

    ko.bindingHandlers.uniqueName.currentIndex 
    

    to

    ko.bindingHandlers.uniqueName.Zb
    

    so now I have:

    define(["knockout"], function(ko) {
        ko.bindingHandlers.valmsg = {
            init: function (element) {
                element.setAttribute("data-valmsg-for", "ko_unique_" + ko.bindingHandlers.uniqueName.Zb);
            }
        };
    });
    

提交回复
热议问题