knockout.js

Using Knockout and Breeze with Cascading Dropdowns

北城余情 提交于 2019-12-14 03:25:10
问题 So I've been at this back and forth for quite a long time now, so I'll just get to the point. I am creating an application based on the HotTowel template, so I'm using knockout, breeze, Q etc. I'm using a breeze query to get some data from the server, and then I load that data into the first select (as options). This changes the selectedModel observable and the subscription triggers ( the subscription is the current "solution", I have used data-bind etc with the same results). The

Custom knockout binding fires twice, unexpectedly

醉酒当歌 提交于 2019-12-14 03:22:29
问题 I have written a custom binding handler to bind my viewmodel data to a highcharts chart. This really has 2 parts, one binds the initial config required for highcharts, the second binds the series to the chart. here is the bindingHandler code ko.bindingHandlers.highchart = { update: function(element, valueAccessor, allBindings, viewModel, bindingContext) { var value = valueAccessor(); var valueUnwrapped = ko.unwrap(value); console.log ('update',element.id,valueUnwrapped); if(allBindings.get(

Hiding a part of column and making it appear through mouseover using knockout

﹥>﹥吖頭↗ 提交于 2019-12-14 03:08:08
问题 I have a table: table class="table"> <thead> <tr> <th>ID</th> <th>Description</th> </tr> </thead> <tbody data-bind="foreach: Curriculums"> <tr> <td data-bind="text: ID"></td> <td> <div data-bind="event: { mouseover: toggle, mouseout: toggle }> <span data-bind="text: curCode"></span> </div> <div data-bind="visible: selected"> <span data-bind="text: curDescription"></span> </div> </td> </tr> </tbody> </table> this is my knockout js var Vm = { Curriculums: ko.observableArray([]), ID: ko

How/when to query 'extended' entities in Breeze

大憨熊 提交于 2019-12-14 03:06:20
问题 I have a ViewModel that loads up 'child' entities and I want to also display 'grandchild' entities based off of each child that is loaded. To simplify things, I need help identifying how to query these objects and display them under the proper 'tree' in the browser (apologies for my butchering of coding language : )) I am using Knockout to bind the data and loading up the entities with Breeze. This question is an extension of When to add extend additional complex types onto a Breeze entity

Knockout checkbox enable dependencies

半世苍凉 提交于 2019-12-14 03:05:31
问题 I'm trying to make checkbox enabling with dependencies. I'd like to enable a checkbox if some of two input fields are not empty. here is my javascript code: var GoogleContactsViewModel = function() { var _self = this; _self.GoogleContacts = ko.observable(); _self.IsEnabled = function (item) { console.log(item); return item.GivenName.length || item.FamilyName.length; }; _self.GetData = function() { $.ajax({ url: "some url", method: "POST", success:function (dataFromServer) { _self

Knockout js , mvc drop down default value is not selecting

 ̄綄美尐妖づ 提交于 2019-12-14 02:59:39
问题 it seems so simple but I am unable to do it. I have bounded a Dropdown list with Json data from c#. View page <div class="col-md-6"> <select data-bind="options: VehicleTypes, optionsText: 'Name', optionsValue:'ID', optionsCaption: 'All', value: VehicleTypeId" class="form-control"></select> </div> Json call Knockout Model var baseModel = { VehicleTypeId: null, VehicleTypes: [], } var viewModel = ko.mapping.fromJS(baseModel); $.get(urlPath + "/GetVehicleTypes", function (data) { viewModel

How to masked an input text box which is data-bound to Knockout computed variable

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-14 02:48:48
问题 I am using jquery MASKED INPUT PLUGIN for masking my input boxes which are data-binded to knockout variables. I have problem in masking if the knockout variable is Computed Variable. Here is the Fiddler Link https://jsfiddle.net/himanshudhiman/2h1f18qo/5/ I am able to mask input boxes of observable array. But I don't get masking option for the input box of Computed Variable(i.e here in my code is "self.SelectById()"). ViewModel function KeyValuePairOfIdAndName(Name, ID) { var self = this;

replace observableArray with new data

╄→гoц情女王★ 提交于 2019-12-14 02:17:23
问题 I have a viewmodel like AppViewModel = { agent : ko.observableArray([ { name : 'test', age : '23' }]) }; My json data comes like {"agent":[{"name":"john","age":"23"},{"name":"conor","age":"23"}]} for ajaxcall evry 3 sec How to replace the view model with new data I tried success : function(responseData) { var data = ko.toJS(responseData); //AppViewModel.agent.push(data); AppViewModel.agent.replace(agent,data); } but doest work. 回答1: All you have to do is set the observable success : function

href vs scripted page transitions and button highlighting

≡放荡痞女 提交于 2019-12-14 01:41:31
问题 I am building a number of jQuery Mobile SPAs along with knockout.js and in general having great success. I did notice what is mostly a cosmetic issue an now hope to solve it. Anchor tags that link via href produce a nice button highlight (in blue for the default theme) affect during a page transition but navigation via knockout's click binding / $.mobile.changePage produces no such highlight. I realize this likely has nothing to do with knockout. Is there any general purpose way that scripted

How to check contain in knockout

六月ゝ 毕业季﹏ 提交于 2019-12-14 01:38:31
问题 I am using knockout and i have one html page where i want to check string with some value. Like i have one string 'A:B:C:D:F:G:H:I', i just want to check this string in html with knockout if. Model var viewModel = function () { var self = this; self.key = ko.observable("A:B:C:D:F:G:H:I"); } View <!-- ko if: key().contains('A') --> <input type="checkbox" checked="checked" value="A"/> <!-- /ko --> <!-- ko if: key().contains('B') --> <input type="checkbox" checked="checked" value="B"/> <!-- /ko