knockout.js

How to pass value in knockout js

假装没事ソ 提交于 2019-12-25 19:45:15
问题 I need to pass value from one javascript to another using function call. I am returning value of month from II js to I js but value is not getting populated in html. Sample code is given below but its not working.Kindly help me to fix this code: HTML FILE ======== <body> <div id="selectdiv"> <input type="radio" id="radio1" name="radioGrp" value='div1' data-bind="checked:subDiv1" />div1 <input type="radio" id="radio2" name="radioGrp" value='div2' data-bind="checked:subDiv1" />div2</div> <div

Knockout bootstrap modal issue

假装没事ソ 提交于 2019-12-25 18:55:38
问题 I try to write by my own a Knockout application in which are available nested arrays. I'm trying to create a Bootstrap modal window which will help me to add a new item of embedded List. I create the everything but unfortunately the new item is always added to the last array. Any idea what I'm doing wrong? What I wrote for now is available on JSFiddle JS ko.bindingHandlers.showModal = { init: function (element, valueAccessor) { $(element).modal({ backdrop: 'static', keyboard: true, show:

How to add datas from JSON data

不羁的心 提交于 2019-12-25 18:25:14
问题 In this fiddle inside view appointmnets tab there is a available hospital drop down which has 3 fields A,B,c. Now I want to make this dropdown from the values that I get from JSON. This is my JSON data { "doctors": [ { "id": 1, "schedules": [ { "id": 1, "totime": "13:19", "dayId": 1, "locati‌​on": "Somajiguda", "fromtime": "12:19", "hospitalId": 5, "day": "Monday", "hospital": "Yas‌​hoda" } ], "username": "doctor", "degree": "MBBS,MD", "email": "a@b.com", "image‌​Path": "imagePathValue",

How to Bind data from Razor to Knockout?

风格不统一 提交于 2019-12-25 16:54:15
问题 I am using KnockOut JS and MVC. How do I bind the data from @ RAZOR view to my databind in KO. I tried doing this but did not return anything at the CONTROLLER. What I am trying to achieve here is that the Razorview renders the rows in Step3(View).I want to bind these rows to the KNOCKOUT so that I can pass this data to the Step4(View). Is there a better way?? VIEW: <tbody data-bind="foreach:ApprTable"> @for (int i = 0; i < UserWRInfo.Count; i++) { <tr> <td style="text-align: center"> <button

cascaded dropdown prepopulate knockout MVC

北城以北 提交于 2019-12-25 16:52:25
问题 I am on the Update details screen and I have a Country and a state dropdown .I want to pre populate State dropdown on the basis of the selected Country. On the initial page load I do have the selected Country,Country Collection and Selected State all I need is to fetch the State Collection using AJAX. Country List: <select id="CountryDropdownList" data-bind="options: viewModel.CountryCollection,optionsText:'CountryName',optionsValue:'CountryName',value:viewModel.SelectedCountry"></select>

AutoComplete Textbox using Durandal JS

北战南征 提交于 2019-12-25 11:04:31
问题 How can I create an autocomplete textbox using durandal JS. Given code not working. viewModel(js) define(['repositories/customerRepository', 'plugins/router', 'plugins/http', 'durandal/app', 'knockout'], function (customerRepository, router, http, app, ko) { return { router: router, activate: function () { var data = customerRepository.listMovies(); $(function () { $("#movie").autocomplete({ source: data, focus: function (event, ui) { $("#movie").val(ui.item.name); return false; }, select:

Knockout binding for DataTables with FixedColumns extension not working as expected

纵饮孤独 提交于 2019-12-25 10:00:07
问题 I am using the knockout-binding suggested here for DataTables. However, when using the FixedColumns extension (which clones the original datatable to a new one) I lose the binding between the new datatable and the existing viewmodel/bindingContext . For instance, having a selection checkbox on a fixed column to select items from the table will not behave as expected. The binding looks like this: ko.bindingHandlers.dataTablesForEach = { page: 0, init: function(element, valueAccessor,

knockoutjs 'Cart editor' example questions

梦想的初衷 提交于 2019-12-25 09:44:13
问题 I'm trying to understand how the variables are observed and mapped. The jsfiddle is here http://jsfiddle.net/rniemeyer/adNuR/. The following 2 lines of javascripts seem to set up the variables for observation: this.category = ko.observable(); this.product = ko.observable(); So how do the above 2 lines do the tricks? How does it know how to map the category and product into the sampleProductCategories[] array? Thanks for the help. 回答1: The fiddle loads a resource that contains all of the

How to get selected value from Kendo-multiSelect?

余生长醉 提交于 2019-12-25 09:42:09
问题 How to get selected value from Kendo-multiSelect ? $("#doc").kendoMultiSelect({ value: , dataSource: { data: self.list() }, }); 回答1: Try var multiSelectedValues = $("#doc").data("kendoMultiSelect").value(); which will give result as ["1", "2","so on"] 回答2: The code below will get the values of the kendoMultiSelect. var doc= $("#doc").data("kendoMultiSelect").value(); 来源: https://stackoverflow.com/questions/42973914/how-to-get-selected-value-from-kendo-multiselect

knockout js, add new item to an array

本秂侑毒 提交于 2019-12-25 09:37:21
问题 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