FAQ Database Discussion Community


$component incorrect within foreach binding inside a KO component

knockout.js,knockout-components
JS Fiddle showing issue: http://jsfiddle.net/davetropeano/58vm9r6g/7/ I have a custom component that renders an observable array. List elements are readonly and I am trying to support letting a user delete an element. Here's the template: <template id="kv-list"> <input type="text" placeholder="key" data-bind="textInput: k"> <input type="text" placeholder="value" data-bind="textInput: v"> <button data-bind="click: add">Add</button><br> <table>...

WHY does it initialize this Knockout.js component in random order?

javascript,html,knockout.js,knockout-components,knockout-templating
I am beyond confused... I am creating a list using Knockout.js components, templates, and custom elements. For some reason, the steps I create in my Viewmodel are being initialized in random order within the custom element definition! And it is completely randomized so that it is different each time! To...

KnockoutJS custom component loader not executing `loadViewModel`

javascript,knockout.js,requirejs,knockout-components
Context I have been fiddling around and trying to create my own (just another) SPA framework. In this framework I've been trying to create a custom component loader to be able to do some dependency injection 'n stuff on the viewModels I'm loading. Used KnockoutJS version: 3.3.0 Problem The loadViewModel...

How can I add HTML to this Knockout.js Viewmodel variable? [duplicate]

javascript,html,knockout.js,knockout-components,knockout-templating
This question already has an answer here: HTML Entities with Knockout 1 answer I have a list of steps displayed on the page. Some steps (but not all) will have 1-3 substeps. I was thinking the simplest way of doing this was to just write the HTML manually within...

Replace container element when using Knockout component

javascript,knockout.js,web-component,knockout-components,knockout-templating
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...

Knockout Components - Custom Component Loaders

knockout.js,knockout-components,systemjs
I'm using Knockout Components and with System.js for module loading. I have a custom component loader: var myComponentLoader = { loadComponent: function(name, componentConfig, callback) { System.import(componentConfig.myLoader) .then(function(loadedComponent) { var result = { template: ko.utils.parseHtmlFragment(loadedComponent.componentTemplate), createViewModel: loadedComponent.MyComponentViewModel } callback(result); }) // .catch(function(myError){ // alert(myError); // callback(null); // }); } }; //...

knockout component parameter handling

knockout.js,parameter-passing,knockout-components
I just don't seem to understand the following: I have a html page that uses a knockout component see code below: HTML: <h2>Home</h2> <p data-bind='text: message'></p> <examlist params="list: StartList"></examlist> So passing a parameter to the examlist In my knockout examlist component viewmodel: define(['knockout', 'text!./examlist.html'], function(ko, templateMarkup) { function Examlist(params) {...