knockout.js

knockout js, add new item to an array

狂风中的少年 提交于 2019-12-25 09:37:07
问题 So this follows on from my previous question: knockout js, add additional elements to an array Basically I have an app where a user fills in certain data, clicks next and this is added to an array. However, what I'd like to do is add some items into the array before the user even begins using the app (these items I get from a database). The idea being that at the start they can view each item in the array and then choose and an item and edit this item. I've got a feeling I'm missing something

knockoutjs deselect/select all checkboxes when one or more items deselected

蹲街弑〆低调 提交于 2019-12-25 09:36:18
问题 This is similar to, but different from other questions around this topic. I have a table with a list of records, each having a select checkbox. In the table header I have a "Select All" checkbox. When the user checks/unchecks "Select All" the records are selected/unselected. This works fine. However, I need to deselect my "Select All" checkbox when one or more of the records are deselected. My markup: <table> <thead> <tr> <th>Name</th> <th><input type="checkbox" data-bind="checked: SelectAll"

ASP.NET/MVC: Knockout-binding preventing client-side validation from being performed?

梦想的初衷 提交于 2019-12-25 09:26:53
问题 This is a follow-up to, or rather replacement for, this question: MVC/ASP.NET: Client side validation not working The issue was, and is, that my ASP.NET/MVC client-side validation isn't being performed, even though it should. Now that I've done more testing, it seems I have identified the core of the problem, so here goes. I have a ViewModel as follows: public class RegisterViewModel { [Required] [EmailAddress] [Display(Name = "Email")] public string Email { get; set; } // some other

How to access and display mapped data with ko.mapping script (Razor page)?

我的未来我决定 提交于 2019-12-25 09:22:31
问题 Java script (getting data using Can`t get json object to with knockout answer {1} method): <script type="text/javascript"> $.getJSON("/api/TelemarketingApi", function (result) { function viewModel() { return ko.mapping.fromJS(result); }; ko.applyBindings(new viewModel()); }) .error(function () { alert("error"); }); </script> JSON object: [ { "TelemCalls": [ {"ID": 1, "duratio": "11"}], "ID": 1, "FirstName": "Jonas", "LastName": "Jonaitis", "Phone": "860123123", "Municipality": null } ] How

Knockout data-bind click

你离开我真会死。 提交于 2019-12-25 09:02:26
问题 I am trying to understand a button on a third party site my company uses. The button signs up a user for a class. <a class="btn btn-large btn-blue" href="javascript:void(0);" data-bind="click: $root.clickAction.bind($data, ActionType)"> <span data-bind="text: Title">Sign up</span></a> I was hoping to provide this button on a page in our company internal website, but I am not familiar with Knockout. I understand a GET request so if that button did something like this then I would get it.

Show/Hide based on Dropdown selection in knockoutJS with model inside another model

喜你入骨 提交于 2019-12-25 08:29:39
问题 I am working on "Rules" for form builder. I want to show/hide text box based on the dropdown selected. For example, let us assume we have a following "Rules" for a "TextField" control under "Form Builder" Rule# Control(dropdown) Condition(dropdown) Value(as input textbox) 1 TextBox_1 Is filled out (Text Input NOT REQUIRED) 2 TextBox_2 Contains Hi From the above, for Rule 1, the text input is not required and for Rule 2, Text Input is required. The above is my scenario. What I tried: HTML

knockout observablearray in 2 templates

余生长醉 提交于 2019-12-25 08:16:58
问题 I have 2 observabeleArrays. One contains all the possible types which I can select and the other one contains all the selected ones. The first template shows all the possible types and the other all the selected ones. If I click on one of first template(all possibilities), it gets added to the list of selected ones and is displayed in the second template. If I click on a selected one in the second template it is removed from there. Also, in the first template I want to display a check on the

changing “with” property changes styles

对着背影说爱祢 提交于 2019-12-25 08:14:19
问题 I have html that looks something like this: <div> <table> <tr onclick="show();"> <td class="cell">Click to open</td> </tr> </table> </div> <div style="display:none; position:absolute; left:150px" id="hiddenDiv"> <table data-bind="with: someProperty"> <tr onclick="hide();"> <td class="cell" data-bind="text:message"></td> </tr> </table> </div> <input type="button" value="Color cells" onclick="colorCells()" /> And my JavaScript looks like this: function show() { vm.someProperty(vm.list[1]); $("

Input file selection event not firing when selecting the same file in KnockoutJS and HTML

*爱你&永不变心* 提交于 2019-12-25 08:09:21
问题 Probably this has a easy solution for JQuery but i am struggling to do with KnckoutJS. When i select the same file then event is not firing. I have a html like this <label class="upload"> <input id="documentattachment" name="documentattachment" multiple type="file" data-bind="event: { change: function() { uploadSelected($element.files) } }" /> {{texts().attachmentFile}} </label> and in viewmodel i have code like this. function uploadSelected(file) { if (!vm.uploadOnSubmit()) { if (!session

Knockout Validation length is always 0

这一生的挚爱 提交于 2019-12-25 07:59:40
问题 I am new to using knockout and I am trying to get the validation plug-in to work. However, I tried ViewModel.errors().length == 0 but it is always zero when i check the isValid - I always get true. Here is the rest of my code, please help. define(['knockout','knockout-validation', 'services/changeup', 'services/currencies', 'plugins/router'], function (ko, validation, changeup, currencies, router) { ko.validation.configure({ insertMessages: true, decorateElement: true, errorElementClass: