Questions tagged [knockout.js]

1

votes
1

answer
288

Views

How to set options value with object in knockoutjs

I have: I dont want only id, i want set in object a id and name of my array when you select an item from the list. Sample: I want this result: idSelected = {id:1, name:'Test'};
joeyanthon
1

votes
1

answer
456

Views

asp.net core 2.1 with knockout

I've been trying to teach myself the ins and outs of .NET Core development, and I've got the start of a Core 2.1 web application created. I've even gotten the hang of EF Core, and have a working DB Context. I am, however, having difficulty figuring out how to implement knockout. I ran the command do...
Kurt
1

votes
5

answer
1.1k

Views

How to check if a knockout observable exists?

Say I have a json of observables : self.name = ko.observable('Arnab'); self.surname= ko.observale('Bhagabati') var person = { name:ko.observable('Arnab'), lastName= ko.observale('Bhagabati') } I can access the name of person by console.log(person.name()); How do I check whether my person has a knock...
Arnab Bhagabati
1

votes
1

answer
91

Views

Fading in container elements in Knockout.js after image has loaded

I have an images and some text that is being generated by Knockout.js. The text shows up immediately while the images takes longer to load. I want to have a class on the container that houses each image/text pair and when the image finishes loading then toggle that class and have the image/text pair...
Housemartin
1

votes
1

answer
24

Views

How does observableArray work?

I have seen people using observableArray in many of the tutorials and using mapping to map data from server to models. How does it actually work and what all are it's use cases ? I understand that observableArray is after all an array of observables packed into one. Thanks. ( I am a noob here, do i...
fuwebesuya
1

votes
1

answer
248

Views

inivisible Google ReCaptcha Integration with Knockout and AJAX Post

I am trying to integrate the Google Invisible Captcha to my contact form. The integration is working to an extent and I can submit my form and the challenge appears. However, I assumed that the data-callback added to the div would call my submit function again after the challenge is completed? So cu...
Matthew Flynn
1

votes
1

answer
50

Views

How do I trigger an event in Knockout JS for a date input?

What I want to accomplish is to trigger an event when the user selects a date from a date input field in HTML using KnockoutJS. Regardless of the date the user chooses, I want to set the first day of the selected month. I don't want to post the date field on a form yet. I want the event to be trigge...
Mirac Kocaturk
1

votes
1

answer
69

Views

Getting the $page context on a kendoListView template

I'm using a kendoListView and I want to display only the item that satisfied my if conditional: #if(variableFromPageId !== Id){# #:Project.Utils.getDefaultName(Name)# #:Project.Utils.getDefaultDescription(Description)# #}else{# console.log('Do nothing!'); # }# The problems is that variableFromPageI...
IBot
1

votes
0

answer
57

Views

knockout observablearray with computed function read and write

I am just new learner about knockout.js. My single page application will have a table that data bind with many records. Each row of table will have 2 input that is requsted count and requested amount after data bind. image1 The 2 input in each row of table is writable with computed function that ha...
scbt10 scbt10
1

votes
1

answer
25

Views

Dynamicly rebinding an extender doesnt update the view

I have an extender that checks the min/max length of a target. I need to set the min/max dynamically based on a dropdown select. If the min/max is out of range, the observable has an hasError, that will update my view with a css class. The issue is once I rebind the extender, the view doesnt update....
PhillyNJ
1

votes
1

answer
56

Views

How Can I change jQuery data handling to Knockout bindings for openWeather API

I'd like to use Knockout data binding to update weather API data in my html div element. Currently, I am using jQuery to update the DOM but I prefer to use Knockout. I also want to dynamically change the location zip so weather is specific to that one location in my div. I have an array for location...
ResSen
1

votes
1

answer
314

Views

How to get file size, image ,height and width before upload? in knockout file binding

I need to check the image size in kilobyte and the dimension (height, width) How can I get the size of the in bytes? 'Max file size reached' error message should be displayed. I can't figure out how to check after Drag and Drop image upload. $('#fileinput').bind('change', function() { alert('This...
eunsang
1

votes
1

answer
37

Views

Give browser access to directory for many file uploads

The project - a page that will allow a user to upload many files for access to many individual users in batch - user 1 will have access to file1.txt, user 2 will have access to file2.txt, etc. The user will upload an excel file that contains the file name, the user ID, and various other details that...
VBartilucci
1

votes
2

answer
42

Views

Knockout JS - tabs in usercontrol not formatting

I've drilled down so I'm pretty sure I know the right question to ask - let's see how I've done. I have a single-page app using Knockout 3.4.0. A main page, with a number of attached user controls. I have a tab set defined on the main page, and it works fine: I have a second set of tabs defined on o...
VBartilucci
1

votes
0

answer
65

Views

NASA world wind map - open navigation URL new window after clicking on custom Placemark

Please suggest me how to perform following scenario using world wind map on the web: open navigation URL new window after clicking on custom Placemark I have tried to register or add event dynamically place work canvas but no luck. Please refer following code. self.createPlacemark = function(locatio...
Hanmant Jankar
1

votes
2

answer
609

Views

Knockout JS: Creating dynamic table columns

Using Knockout JS: I have a requirement as. I have a table with 2 static columns where each has a text-box. I also have a add row button outside the table and one remove row button along each row. When the user clicks add row it adds a row to the table and I can see two columns with textbox in each....
kaka1234
1

votes
1

answer
62

Views

combining knockout js with truffle app.js

I am learning on how to create a voting app with truffle and rendering on the screen everything goes well. So now I don't want to use vanilla js but want to add a framework to it, called knockout.js I tried it in everyway but for some reason the knockout js is not working inside the app.js file give...
Masnad Nihit
1

votes
2

answer
33

Views

Change properties of an object in an observable array with a Colorpicker

I have to use data bind on the two colours of a header (one for background, one for text), but I don't want to create two separate observables, just an array with a single object with two properties: MainColor and SecondaryColor initialized with a hex value. (A colorpicker for each property changes...
Enrico Casanova
1

votes
0

answer
48

Views

KnockoutJS Validation - Child validation rule OnlyIf based on parent viewModel field?

I'm using KnockoutJS on an ASP.NET application using the knockout-validation extension. I have parent and child viewModels. I need one of the fields in the child viewModel to only be required when a field in the parent viewModel has a value of X. This is what I currently have, but this doesn't work:...
James Ludlow
1

votes
0

answer
44

Views

Accessing and replacing values in a Knockout Observable Array

I've been having difficulty understanding how Knockout Observable Arrays work, more specifically replacing certain vales within them. I keep thinking I've got it right until further down the line when something else doesn't work correctly. Due to the complexity of my viewmodel (Observable Arrays of...
James Morrison
1

votes
1

answer
46

Views

KnockoutJS - Comparing observableArray with another observableArray

I have a json data formatted like this { 'ITEMS': [ { 'option': 'one', 'values': ['A','B','C','D'] }, { 'option': 'two', 'values': ['E','F','G']] } ] } and script code like this function Item(data) { this.option = ko.observable(data.option); this.values = ko.observableArray(data.values); } var Pro...
Nabil
1

votes
0

answer
44

Views

Require.js - order of loading libraries?

Im trying to make Single Page Application (with Knockout.js - it's necessary to use it) which imitates products page in online shop. Here's how it looks like (for better understanding): main page Im using require.js, knockout.js and underscore.js for filtering items by price. The problem is - somet...
Tymur Yunusov
1

votes
1

answer
72

Views

Update razor collection via knockout

I have this UI And my goal is to update table after clicking Update button based on Id and Description parameters I have following code Html Id Description @foreach (var item in Model.Products) { @item.Id @item.Description } Id Description Update JavaScript // Plain javascript alternative to jQuery....
Muflix
1

votes
0

answer
30

Views

Knockout observable about an object property with a method value fails on IOS 11.3 (FIX)

Our product failed on IOS 11.3 with a generic, 'problem repaetaed occured on '. It would work fine when connected to a remote debugger on MAC making it hard to find out the cause. I have invested considerable time on it to find out the actual cause. It was hard because we use a huge internal framewo...
mr.G
1

votes
1

answer
396

Views

Oracle JET - Creating chart with JSON-data

I'm trying to populate a pie chart with some JSON-data. My datasource is restcountries.eu/rest/v2/all. I retrieve the data with a $.getJSON and I create a temporary array which in turn is used as a datasource. I then bind the source to the pie chart. That what I think I'm doing atleast.. The error I...
absoluteRango
1

votes
1

answer
41

Views

Knockoutjs grid event invoke by code

I have grid populated as below The click event is as below (in ViewModel) self.WClickFunction = function (data, event) { //Code here to highlight the selected row }; This grid is within a div and this is opened using jquery UI dialog $('#griddiv').dialog('open'); This works fine when dialog loads an...
rkr
1

votes
0

answer
35

Views

knockout template from string must create a custom binding?

I want create a universal table components by knockout.this component must support custom template show if have a params 'templ' : tableParams = { ... { title: 'factory', name: 'FAC_NO', isKey: true, templ: '', validation: { required: true, maxLength: 4 } } ... I want support template by string not...
fe263
1

votes
1

answer
44

Views

fire onchange event on textbox using knockout

here am working on a snippet to get the calculations done using knockout and attached is the fiddle. https://jsfiddle.net/naren_net/55etxj4y/272/ var vm = function() { this.PrevActualQty = ko.observable(); this.PrevUnitCost = ko.observable(); this.PrevTotalCost = ko.observable(); this.ChangeQty...
user3056037
1

votes
0

answer
34

Views

Access Knockout Function from External Function

There's a few similar questions relating to what I'm after, but I haven't found any related specifically to my issue. I'm using Knockout with success throughout the website I'm building, however, have come up against a brick wall when trying to access a ViewModel function from an externally hosted f...
user2986913
1

votes
0

answer
63

Views

Knockout JS - lost binding after manipulating DOM

I am lost in the next situation. I am using Knockoutjs (v3.4.2). I have this viewmodel: var vm = { items: ko.observableArray([ { label: 'test' }, { label: 'test2' }, { label: 'test3' }, { label: 'test4' } ]) }; And this template: My binding: ko.bindingHandlers.sortable = { init: function(el) { let m...
Wim te Groen
1

votes
1

answer
100

Views

filtering observable array from drop down menu in knockout.js

I only started learning about and using knockout.js a few days ago. I have been working through the interactive tutorials on thier website and other related beginner excercises and have formed a basic understanding. I am trying to create a 'log handler' application that will basically display some...
c_user
1

votes
2

answer
43

Views

Not able bind the data to class variables while using success call back of $.get in typescript

I am using TypeScript. I am trying to bind the response from rest API to a variable in a ViewModel like below: export class TestListViewModel { public personItems: KnockoutObservableArray; constructor() { this.personItems = ko.observableArray([]); this.person1 = new Person(); this.person1.name = ko....
Avinash
1

votes
0

answer
26

Views

Durandal js, all functions activate at startup

i have a SPA written with Durandal js and knockoutJs packs, when i run the program all the function () functions triggered at startup, most of the must be triggered by some actions (like, click events etc...) and it works fine, but i do not need it to be trigger at startup. how can i control it? her...
Michael meshaev
1

votes
0

answer
61

Views

How can I make nothing happen when hitting enter in a empty search/text box

I have an order page with a search/text box, in which I can filter by product name or code. The issue I am having is that, when you press Enter in the empty search/text box, then nothing should happen but the add items to order modal box pops up. This issue only happens, when using Internet Explore...
Kash
1

votes
0

answer
62

Views

Json Object always return undefined from rest Api

my question is about json object conversion. i am invoking rest api from knockout js in console its returning accurate data but when i want to select any object value then it always return undefined here is the code which i am using to extract value from json object. }).then(function(response) { var...
1

votes
2

answer
46

Views

How to get the value of an observable using knockout

I'm trying to access to the value of an observable from an other script that the one where the view model is defined, but I've no idea how to do that. Let me explain the thing: My view model is defined in monitoringviewmodel.js and used in MonitoringTask.cshtml where I display the data passed from i...
Bastien Antoine
1

votes
2

answer
32

Views

Ko Bindings after @Html.Partial do not work

I Have the following code cshtml @Html.Partial('Documentos') SALVAR and the following binding ko.applyBindings(model, document.getElementById('dvUserData')); But my data-bind='click: editData' does not work, the click is not performed. But if i put the div class='col-md-3' before the @Html.Partial(...
1

votes
0

answer
56

Views

Knockout store element reference for later use

This is probably super simplistic and I'm probably just missing it but... I want to save off a reference back in my ViewModel to an element, so that I can manipulate that element from a completely different function later. To make a short story long, I have a simple list created with a foreach loop...
Randy Hall
1

votes
0

answer
53

Views

Asp.net Web Forms and Knockout - Maintaining State

I am trying to maintain state in my asp.net wizard that uses knockout with hidden fields. I am saving my textbox and DDL user selected value to hidden fields on the page. When the user traverses back to this webpage, I am using hidden fields to populate the controls back to previously selected valu...
user877247
1

votes
2

answer
238

Views

ko.mapping || Cannot read property 'fromJS' of undefined

I am new at typescript. I've been trying to use knockout.mapping with it, however, i can't make it work. I've installed the libraries of knockout and knockout.mapping, also the @types from the two libraries, and even in that way can't that work. I am using typescript in a laravel project and i am us...
Dilakv

View additional questions