knockout-components

Replace container element when using Knockout component

你。 提交于 2019-12-01 17:57:05
Is there a way to configure a Knockout component to replace the container element instead of nesting its content inside the container element? For example, if I have a custom component registered as my-custom-element with the following template: <tr> <p>Hello world!</p> </tr> Is it possible to use the component like this: <table> <tbody> <my-custom-element></my-custom-element> </tbody> </table> And have the final product be this: <table> <tbody> <tr> <p>Hello world!</p> </tr> </tbody> </table> Instead of this: (the way Knockout renders components by default) <table> <tbody> <my-custom-element>

Issue loading knockout components view model using requireJS

风流意气都作罢 提交于 2019-11-29 07:57:49
I am working with the new components functionality of knockout 3.2 and trying to load the components using requireJS. However, I am having a weird issue. Basically, when I hardcode the view model in the register function everything works fine. When I try to load the exact same view model using requireJS, it's not working correctly. Here's a sample of the html to load the component: <div data-bind="component: { name: 'test'}"></div> Here's the html in the template that this component will load: <a href="#" data-bind="click: addNew">add</a> <span data-bind="visible: Adding">test</span> When I

Does afterRender work with Knockout components?

旧时模样 提交于 2019-11-27 19:03:19
afterRender works with template bindings, but after converting my templates to components, there does not seem to be any way to use afterRender . I have tried looking for an example of a component that uses afterRender , but cannot find anything. I could not get the method working as per the above post. However i found a workaround on the git issue list and it doesn't require a custom KO Binding. Add the below line in your component template html or string of code. <span data-bind="template: { afterRender: init }"></span> Then create a init function in your module / viewModel: this.init =

Does afterRender work with Knockout components?

。_饼干妹妹 提交于 2019-11-27 04:20:34
问题 afterRender works with template bindings, but after converting my templates to components, there does not seem to be any way to use afterRender . I have tried looking for an example of a component that uses afterRender , but cannot find anything. 回答1: I could not get the method working as per the above post. However i found a workaround on the git issue list and it doesn't require a custom KO Binding. Add the below line in your component template html or string of code. <span data-bind=