Using KnockoutJS with detached nodes

前端 未结 3 974
逝去的感伤
逝去的感伤 2020-12-21 05:07

What I\'m looking to do is detach some nodes using jQuery\'s detach method, update my ViewModel, attach my nodes back, and have the values be updated.

Is this possib

3条回答
  •  我在风中等你
    2020-12-21 05:46

    It's a while since you asked the question, but I have found using detach, then immediately append to some valid location in the DOM keeps all bindings working nicely. You may then detach, append to wherever you need it as your application changes state.

    I use it for sections with multiple events attached, like JQUI elements, forms and the like so that I can keep one copy running around, and just append to the page I go to. eg. a Signup form, which also functions as Edit Profile.

    In your case, initially appending it into a 'visibility:hidden;' node at some point that was clearly for detached elements could be reasonable.

    Don Have a great day

提交回复
热议问题