knockout.js

Child collection mapping not firing

£可爱£侵袭症+ 提交于 2019-12-13 06:49:04
问题 I have used the search engine, and found alot of answers, but I am stuck on a problem. The problem is that the child collection mapping seems to not fire. In the below code the alert "Groups created", but the "Root created"-alert is shown. var mapping = { 'Groups': { create: function (options) { var lang = ko.observable(ko.mapping.fromJS(options.data)); alert('Groups created'); return lang; } }, create: function (options) { var innerModel = ko.mapping.fromJS(options.data); alert('Root created

Kendo-Knockout: widget observable is not filled with the actual widget

Deadly 提交于 2019-12-13 06:44:21
问题 I am using RPNiemeyer`s kendo-knockout library. I have a kendo window: HTML: <div data-bind="kendoWindow: {isOpen: isOpen, title:'Language', width: 400, height: 200, modal: true, widget: popUpWindow }" > JavaScript part that centers the window: this.popUpWindow = ko.observable(); self.isOpen.subscribe(function (newValue) { if (newValue) { self.popUpWindow().center(); } }); I am using the source code from my previous question for my fiddle: Kendo-Knockout: Window does not close correctly I am

YUI DataTable using KnockoutJS bindings

时间秒杀一切 提交于 2019-12-13 06:07:44
问题 I have an example working at JSFiddle. It has a piece of JSON consumed by a YUI DataTable which I need to create using KnockoutJS bindings. I'm fairly new to KnockoutJS and would like to know how this can be done. The table should be created under the markup - <div class="yui3-skin-sam" id="datatable"></div>​ The code goes as below - YUI().use('datatable', 'datasource-local', 'datasource-jsonschema',function(Y){ var data = {"generations": [{ "type": "Modern", "showName": "The Modern

Modify and Call Custom Binding In Knockout.js Explicitly

喜你入骨 提交于 2019-12-13 05:49:57
问题 Can I call the custom binding called form from another custom binding called addAnother explicitly? Also can I modify the parameters going into the parent custom binding? ko.bindingHandlers.addAnother = { init: function (element, valueAccessor) { $(element).click(function () { //$(element).parents('form').... }); } }; <form class="box clearfix" action="@Request.RawUrl" data-bind="form:{ id: @Model.Division.Id }"> @Html.Partial("EditorTemplates/Division", Model.Division) <div class="control

Knockout: Add items into nested json hierarchy

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:49:18
问题 I would like to know how to add items within a nested hierarchy. I was able to do it when I was not using the mapping plugin, but only in the top level. Here's the Fiddle: https://jsfiddle.net/kyr6w2x3/3/ <input type="text" data-bind="value: newSlideTitle" placeholder="Awesome slide name"> <button type="button" data-bind="click: $root.addSlide.bind($parent, $data)">Add slide</button> self.removeSlide = function(slide) { this.slides.remove(slide) }; self.addSlide = function(slide) { this

How to solve the Maximum call stack size exceeded issue in JavaScript Code

孤者浪人 提交于 2019-12-13 05:26:45
问题 As shown below I am using knockout. I have multiple view models which I am combining and passing through to the controller . The problem is that when I run the application, upon clicking F12 to check for errors while the browser is open I came across this small issue: Uncaught RangeError: Maximum call stack size exceeded function FullEmployeeProfile () { var EmployeeEdu = new employeeEducation(); var EmployeeHist = new employeeEducation(); var EmpInfo = new employeeEducation(); } function

knockout dropdown validation on load? required

你说的曾经没有我的故事 提交于 2019-12-13 05:17:53
问题 There are many post on this one which i find not helpful and i need to find out why and how . I made a fiddle with two controls dropdown and textbox and applied required validation with .extend My fiddle Question 1 : when i first load my page i get a validation error beside dropdown but not beside textbox ? i am confused why is that . Question 2 : Ok . its awkward to display a error message on load so i planned to disable error messages display on load . Added this line ko.validation.init({

knockout js data binding not updated

非 Y 不嫁゛ 提交于 2019-12-13 05:15:24
问题 I am working on a SPA that contains multiple areas that I dynamically load into a div (id=#main). In order to achieve such I use SammyJS for the routing and knockoutjs for the binding. The particular subpage is loaded like $('#main').load('pages/subpage.html'); where the subpage contains two divs that are switched (master/detail pattern). The data is loaded using .getJSON('data.php',....) into an observableArray within the knockout Model created. Everything works fine and a list of the items

knockoutjs how to call applybindings with viewmodel function indirectly

流过昼夜 提交于 2019-12-13 05:13:32
问题 This should be an easy question, but I just can't figure out how to do it or find the right answer. I'm trying to implement the changeTracker here but I have a viewModel function, not just a variable. I'm currently using var viewModel = function () { // code } and applying bindings using var vm = new viewModel(); ko.applyBindings(vm); How do I incorporate the changeTracker into my application? I tried var vm = new changeTracker(viewModel()); and var vm = new changeTracker(new viewModel());

jquery eventbinding in collapsible menu while using knockout template

不打扰是莪最后的温柔 提交于 2019-12-13 05:06:21
问题 I have the following view in MVC , where I am trying to render a collapsible menu. @{ ViewBag.Title = "Details"; Layout = "~/Views/Shared/_Layout.cshtml"; } @section Scripts { @Scripts.Render("~/bundles/jqueryval") <script type="text/javascript" src="@Url.Content("~/Scripts/knockout-2.2.0.js")"></script> <script type="text/javascript" src="@Url.Content("~/Scripts/moment.js")"></script> <script type="text/html" id="problemTemplate"> <li>ID# <span data-bind="text: ProblemID"/> <ul data-bind=