Is possible to make dynamically changed JS object as a Knockout JS observable? I mean I have this.statuses = ko.observable({}) and when I call API and get response, I’ll put the message here under some “identifiers”. Later I need to get any “last” status if necessary: and in the …
Tag: knockout.js
set knockout.js value programatically from “outside”
I am brand new to knockout.js – I have taken over an existing app written in it, the previous maintainers having left – and I want to start by writing tests that exercise the whole thing from outside it. Most pages are quite straightforward, but I’ve encountered this: this is inside a with, …
Unable to define this context in document.eventListener
I am implementing a scenario in which on clicking outside the drawer, i want to execute the saveChange action but somehow it is giving me the error that saveChange is not a function. I tried different ways to set the context but it is not working. Error : Answer this is because in your event listener, this re…
Knockout JS with Bootstrap Modal
I have a simple page with a button which triggers a modal to open. I have all my code in this JSFiddle: JS Fiddle Also below: I have 2 tabs inside the modal. First tab has some content with some variable text. I am using Knockout JS to fill out the variable text in the content. However, the first time
Get index of item in a loop to be used in if statement to get value in another object
I’m trying to use the index of the current item in a loop to grab a value from a parent object, I’m only able to get the data if I put the number directly in. However, I need to use the index instead. So Parent object contains Library, Books and Book prices Any ideas/suggestions how I can use the …
selected option is not updated when observable updates, though optionsValue does
In the following code, a product (represented with productVM) has an observable property (productName) containing its name in two languages (english and french). Once a cartItem is added, and a product is selected, I want its displayed name to be updated when the button “change language” is clicke…
Bootstrap multiselect blur event not triggering
I’m trying to do some logic after user completes a selection and moves away from a bootstrap multi-select dropdown. I tried hooking into the blur event: Defining a onBlur function in my viewModel: But it never kicks-in. I even tried setting the event binding directly without the $root.onBlur, just blur:…
How to export a HTML table to Excel supported by Chrome and IE?
On my MVC project I have a HTML table bound with Knockout. I’m trying to Export the table to Excel. I tried on client side with JavaScript: OR: But both codes work in Chrome but not in IE. I would like to do it on client side using JavaScript or jQuery but if there is not a solution that is
“placeholder” attribute using knockout – JSON
I would like to use placeholder attribute using data-bind but I have a error message([object object]) . Please let me know how can I use it. html: json: Answer The placeholder attribute should be a string (ko.observable), not an object. Simple example: http://jsfiddle.net/xtdL7om1/
Update Knockout `attr` binding from DOM instead of from ViewModel
I am using Knockout.js to populate a set of HTML5 <details> elements. Here is the structure: The data in the ViewModel looks something like this: I have added the ability to remember the open or closed state of the details view using the isOpen property of the ViewModel and an attr binding (As originall…