knockout.js

Remove duplicate from KOObservable array

痞子三分冷 提交于 2019-12-24 11:04:45
问题 Want to remove duplicate values from KoObservableArray. I have following JS file. I want to bind the name column in the UI as dropdown as well as to remove the duplicate values. Suggest the best way to do the same. JS File $(function () { var initialData = [ { name: "Well-Travelled Kitten", sales: 352, price: 75.95 }, { name: "Speedy Coyote", sales: 89, price: 190.00 }, { name: "Furious Lizard", sales: 152, price: 25.00 }, { name: "Furious Lizard", sales: 213, price: 25.00 }, { name:

Oracle JET: Knockout not updating variable

拟墨画扇 提交于 2019-12-24 10:59:25
问题 I have the following oracle jet and knockout html file <oj-dialog style="display:none;width: 600px;" id="addNewTag" title='Tag New Build' cancel-behavior='icon'> <div slot="body"> <div class="oj-form-layout"> <div class="oj-form oj-sm-odd-cols-12 oj-md-odd-cols-4 oj-md-labels-inline oj-form-cols-labels-inline oj-form-cols-max2"> <div class="oj-flex"> <div class="oj-flex-item"> <oj-label for="releaseVersion">Release Version</oj-label> </div> <div class="oj-flex-item"> <oj-input-text id=

JSON.NET class name as root

让人想犯罪 __ 提交于 2019-12-24 10:56:23
问题 I'm working with ASP.NET MVC4 WebApi and Knockout.js. My model consists of Pages that contain 1-N Controls . When I need to load a new Page , I will fetch the HTML View and the JSON serialized object and put all together with KO. As my model is very dynamic, I'm going to use the KO mapping plugin so I don't have to define all the observables. Here is my (very simplified) model: public class Page { public string Name { get; set; } public List<Control> Controls { get; set; } } public abstract

Nested Table With KnockoutJS Observable array's(Parent & Child Table)

ぐ巨炮叔叔 提交于 2019-12-24 10:37:15
问题 I am trying to build a Nested Editable gridview with KnockoutJS, and I have no idea where or what to do with it. I have started the process by obtaining JSON data from my server and using the Mapping Model to map the required JSON info. I even have the Parent grid with all the required Values. Now Based on the selection of the parent grid it should Pass 2 values to the Child then the Child JSON method should appear. And because it's knockout obviously it should be completely observable. Here

How to set `data` attribute value to `option` when using knockout `options` binding

别等时光非礼了梦想. 提交于 2019-12-24 10:28:15
问题 In knockout's documentation, it mentions optionsAfterRender . I was trying to add data attribute value without succeed. Here's the sample from the doc: <select size=3 data-bind=" options: myItems, optionsText: 'name', optionsValue: 'id', optionsAfterRender: setOptionDisable"> </select> <script type="text/javascript"> var vm = { myItems: [ { name: 'Item 1', id: 1, disable: ko.observable(false)}, { name: 'Item 3', id: 3, disable: ko.observable(true)}, { name: 'Item 4', id: 4, disable: ko

Running a callback once an element is created

时光毁灭记忆、已成空白 提交于 2019-12-24 10:18:10
问题 Problem: I am creating an element via a JS templating system. Inside that template I am specifying an ID. After that ID is created, Is there a way with jQuery to fire a callback when a specific element is created? Example JS/HTML with Knockoutjs: function Dialogs(){ this.createDialog = function(id){ //alert('creating dialog'); // If i add a setTimeout here, it will work. $("#" + id).dialog({ autoOpen: true, resizable: false, width: 360, height: 200, dialogClass: 'systemError', modal: true,

Asp.net Web Forms and Knockout - Maintaining State

一笑奈何 提交于 2019-12-24 10:17:14
问题 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 values. Problem : I am able to Populate UI textbox Fields(Control ID - BasicSwitchName) with previously selected values but not with any DDL Controls(Control ID - BasicSwitchManufacturer) except when I

Knockout unable to process binding in a specific function

随声附和 提交于 2019-12-24 09:27:12
问题 I am new to knockout and have a problem with a particular binding. I am using SharePoint to get user properties, display them and save it to a sharepoint list. I have other bindings and they work well. Here is what I have: <div id="custom-new-form"> <a data-bind="click: $root.AddRow" href="javascript:void(0)">Add</a> <table id="sales-returns-table" data-bind="visible: EntityRows().length > 0"> <thead> <tr> <th>Entity</th> <th>Role</th> </tr> </thead> <tbody> <tr> <!--<td data-bind="text: (

using a conditional on a knockout binded value

半腔热情 提交于 2019-12-24 09:17:45
问题 so i am using knockout to bind some set of values to a grid, using the foreach something like i have below. <table id="pcc-batch-list" class="table table-striped" > <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> </tr> </thead> <tbody data-bind="foreach:stuff"> <tr> <td data-bind="text: Something1"></td> <td data-bind="text: Something2"></td> <td data-bind="text: Something3"></td> <td data-bind="text: Something4"></td> </tr> </tbody> </table> and I want to

Need a good approach to conditional value changing. (ASP.NET MVC)

岁酱吖の 提交于 2019-12-24 09:13:28
问题 Today I am tasked with an issue that I have been pondering for a while. I have a form on a page that, when an item is selected from a dropdown, there is a database call that gets information and sets a Required Date field according to the retrieved data. This works fine, but I have the dropdown set to knockout's change event binder, and when revisiting the page for an update, this event runs twice before the user interacts with the page , thus setting the Required Date to whatever the