knockout.js

Creating advanced KnockOut binding handler for google.visualization.datatable

情到浓时终转凉″ 提交于 2019-12-25 06:24:11
问题 Thanks to this tutorial I managed to create a KnockOut binding handler for Google's DataTable. This is my binding handler, so far: ko.bindingHandlers.dataTable = { init: function (element, valueAccessor, allBindings, viewModel, bindingContext) { var table = new google.visualization.Table(element); ko.utils.domData.set(element, "dataTable", table); }, update: function (element, valueAccessor, allBindings, viewModel, bindingContext) { var value = ko.unwrap(valueAccessor()); // Get options: var

KnockoutJS: Make nested sortable automatically expand when adding a child

不想你离开。 提交于 2019-12-25 05:50:42
问题 In the attached example I have a nested sortable that is capable of displaying tree structures. The goal is to make the structure expand when new child is added to make the change visible. A function automatically expands the structure when a new item is being added, but it only expands after adding 2nd child , it should expand immediately after adding 1st child. Something is probably wrong with the template, or a simple jQuery+CSS trick could solve the problem, but I can't find the right one

Knockoutjs simple cascading selects

China☆狼群 提交于 2019-12-25 05:43:39
问题 I'm trying to do a simple cascading combobox using knockoutjs. My first combobox binds to 2 properties in the viewmodel: BusinessLines as the source for comboboxoptions SelectedBusinessLine as the selected item in the first combobox. Each BusinessLine has a collection of Clusters. The second combox should data bind to the SelectedBusinessLine.Clusters observable for combobox options source, and SelectedCluster for the selected option. The problems is that the second combobox doesn't get

Knockout GridView How to Delete Line?

假装没事ソ 提交于 2019-12-25 05:18:17
问题 Here is my HTLM Page: <!DOCTYPE html> <script src="Scripts/knockout-3.4.2.js" type="text/javascript"></script> <script src="Scripts/jquery-3.1.1.min.js"></script> <script src="Scripts/knockout.simpleGrid.js"></script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Knockout GridView Örnek</title> <style> body { font-family: arial; font-size: 14px; } .liveExample { padding: 1em; background-color: #EEEEDD; border: 1px solid #CCC; max-width: 655px; } .liveExample input {

Hide Validation messages onLoad ? Knockout

戏子无情 提交于 2019-12-25 05:15:43
问题 I been trying to hide error messages onload and i want them to display on save . i succeeded in many scenarios and i am able to adjust my code accordingly but this seems to be continious bug i am unable to get rid of it . My function : function work() { var self=this; self.Time= ko.observable(""); self.Validation = ko.validatedObservable([ self.Time.extend({required:true}) ] ); self.calculate=ko.computed(function(){ return self.Time() * 2 ; }); } I added a Watch on this line self.mainArray

How to update/filter the underlying observable value using a custom binding?

爷,独闯天下 提交于 2019-12-25 05:06:12
问题 Problem I have created a custom binding that replaces html br occurences in an observable with \r\n in order to be displayed in a textarea. This works OK for the initial display of the value, but furthers changes to the displayed text don't trigger the update function of the custom binding. Code ko.bindingHandlers.Br2Nl = { init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { }, update: function (element, valueAccessor, allBindingsAccessor, viewModel,

knockout recursive mapping issue

风流意气都作罢 提交于 2019-12-25 05:03:26
问题 this post is a follow-up to this one. I've updated the code as followed: viewModel.getQuotesSuccess = function (result) { var myCoverQuotesViewModel = function (data) { var self = this; ko.mapping.fromJS(data, {}, self); self.Childs = ko.observableArray(ko.utils.arrayMap(data.Childs, function (c) { return new myCoverQuotesViewModel(c); })); self.selectedChild = ko.observable(); self.showChildren = ko.computed(function () { return self.selectedChild() && self.selectedChild().Childs().length >

KoGrid how to refresh grid in case data is changed

∥☆過路亽.° 提交于 2019-12-25 05:02:03
问题 I am tring to use KoGrid lib, but I got case that I can't resolve. I don't know how to refresh grid in case if I got new data for display. I need to update data after ajax call. $.ajax({ type: "GET", url: reqvesturl, cache: false, dataType: "jsonp", success: function (data) { resultData = data; if (!model) { model =new mainViewModel(); ko.applyBindings(model); } else { model.myData(data); //mo.applyBindings(); }; //model.myData(data); }, error: function (jqXHR, textStatus, errorThrown) { } })

knockoutjs table inline template troubles

拟墨画扇 提交于 2019-12-25 04:53:22
问题 I slimmed down my actual code but I can't get this work. I am using knockoutjs and bootstrap with inline knockout templates. I use to just put a bunch of input's inside a div but I changed it to a table for alignment reasons. I know the property names are correct and the javascript console doesn't show any errors at all for bad variables or binding issues. I am putting the foreach in a TR tag instead of the TBODY tag because I don't know how many checkboxes I will have every time and I don't

Assign Dynamic templates

馋奶兔 提交于 2019-12-25 04:53:11
问题 I am trying to use KnockoutJS to develop a wizard for my asp.net app. This is my first attempt at using KO. What I am trying to achieve is assign dynamic templates based on a Click event of an anchor tag. My HTML looks like this <script id="ParamHomeTmpl" type="text/html"> <section class="alert alert-info"> <div class="panel-heading h3 blackincolor"><i class="fa fa-exclamation-circle redincolor" style="margin-right: 5px"></i>Please Select Parameter Type</div> <ul class="blackincolor list