knockout-2.0

Using Knockout to Populate Bootstrap Rows and Spans

佐手、 提交于 2019-12-31 16:43:29
问题 Well essentially I'm trying to populate a Bootstrap template via Knockout and a JSON object. Bootstrap scaffolding: <div class="row-fluid"> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> </div> <div class="row-fluid"> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> <div class="span4"> <h1>App Title</h1> <p>App

Using Knockout to Populate Bootstrap Rows and Spans

拥有回忆 提交于 2019-12-31 16:42:18
问题 Well essentially I'm trying to populate a Bootstrap template via Knockout and a JSON object. Bootstrap scaffolding: <div class="row-fluid"> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> </div> <div class="row-fluid"> <div class="span4"> <h1>App Title</h1> <p>App Description</p> </div> <div class="span4"> <h1>App Title</h1> <p>App

Knockout checkbox change event sends old value

筅森魡賤 提交于 2019-12-31 09:12:52
问题 I'm having a problem with knockout "checked" binding. It seems that "change" event at checkbox return old value, before it is updated(so if it was unchecked it will return false). I don't think that I can subscribe to the value since I have it inside object. <tbody data-bind="foreach: Categories"> <tr> <td><input type="checkbox" data-bind="checked: ShowOpened, event: { change: $root.CategoryChange }" /></td> </tr> </tbody> <script type="text/javascript"> var Category = function (Id, Name,

$index+1 in Knockout foreach binding

风格不统一 提交于 2019-12-31 08:42:33
问题 I need to display $index+1 in a table. If I just use the $index all the elements will start from 0, I need to start at 1. Here's the documentation of knockout: http://knockoutjs.com/documentation/foreach-binding.html In there you can find this example: <h4>People</h4> <ul data-bind="foreach: people"> <li> Name at position <span data-bind="text: $index"> </span>: <span data-bind="text: name"> </span> <a href="#" data-bind="click: $parent.removePerson">Remove</a> </li> </ul> <button data-bind=

Edit item in knockout observableArray

拟墨画扇 提交于 2019-12-31 03:42:07
问题 I am looking for an example where i can show an observableArray as normal text with edit / delete links. Items can be added/edited from a separate form. I am not able to edit the record from edit link it add new record! self.editItem = function (p) { //edit code ////??????? }; Here is example 回答1: As other mentioned in there answers, you should use with binding for editing any particular record. Here i have created a demonstration according to your need. http://jsfiddle.net/85afB/1/ 回答2: You

How can I get a leaflet.js instance using only a DOM object?

好久不见. 提交于 2019-12-30 06:35:49
问题 I'm right now building a custom Knockout.js binding to handle drawing of polygons. In this case the Knockout API only gives me a reference to a DOM object to access whatever it is I need to update. However, it looks like by design leaflet.js wants the user to store the map instance in their implementation. I don't have that option. Trying this gave me an error: var existingMap = L.map('aMapIDGoesHere') And the error was: map already initialized . Any way I can use a DOM element or element ID

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 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,

Edit functionality in form using knockout js

帅比萌擦擦* 提交于 2019-12-25 02:26:56
问题 Hi i am working on a form using knockout js i have to perform CRUD operation. Out of these i am able to do all except update(edit). I want on click of edit same form will open as open on click on addperson but with the values of person. here is my code <html> <head> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript" src="knockout-3.1.0.js"></script> </head> <body> <a href="#" data-bind="click:addFields">ADDPerson</a> <a href="#" data-bind="click

knockout - issue with accessing a nested property

橙三吉。 提交于 2019-12-25 01:56:25
问题 I'm trying to learn knockoutjs by studying existing sourcecodes and making small changes to them.. The source code that I'm trying to understand here is an example of knockout-sortable.js by RP Niemeyer. The original example code is here I have made some small changes which are here The original code has a global property called maximumstudents which checked the number of students in each table. I have added a property in table called "maxstudents" which will decide how many students can sit