knockout.js

knockout sammy.js navigation issue

元气小坏坏 提交于 2019-12-13 18:20:12
问题 I have a scenario like this. Initially loaded when page is navigated to #Action. Once the select action is performed data-bind="with tag is loaded" User click on "Do Something" action is performed. Which replaces the whole "parentNode" Now When the user clicks back, and the sammy.js notices the hash tag #Action/:id, I need to load the #Action to get back the main View and then select the id to load the data-bind="with" tag again. How can I do this? Currently the page does go back to "Action/

Add data-bind property to a boostrap-treeview node for Knockout

守給你的承諾、 提交于 2019-12-13 16:32:43
问题 Is there a way to have "data-bind" properties added to a node when using the bootstrap-treeview ? https://github.com/jonmiles/bootstrap-treeview I have rendered a treeview, but I need to bind a click event to interact with my knockout ViewModel. For a node, I need to add data-bind="click: ViewNodeData" to each node. A node, once rendered, looks like this: <li class="list-group-item node-tree" data-nodeid="13" style="color:undefined;background-color:undefined;"> <span class="indent"></span>

PHP receive json

与世无争的帅哥 提交于 2019-12-13 16:24:38
问题 I'm using knockout and this is my ajax code: save: function() { $.ajax({ url:"http://localhost/loyalty/welcome/json/", type: "post", data: ko.toJSON(this), contentType: "application/json", success: function (result) { alert(result) } }); } Using firebug I can see that the json message is sent correctly, the problem is how to receive it on PHP, what is the name of what has been sent? I'm using CodeIgniter Thanks in advance for any help. 回答1: It would be in the variable $_POST['key'] where 'key

knockout: why does my computed function push items into my observable array automatically ?

半世苍凉 提交于 2019-12-13 16:14:34
问题 I have a computed function, that gets data from a websocket call and pushes it into my observable array onlineFriends.friendIsOnline = ko.computed(function () { socket.on('friend joined', function(data) { console.log(data); var newObservableItem = onlineFriends.friend(data); console.log(newObservableItem); onlineFriends.friendsOnline.push(newObservableItem); console.log(onlineFriends.friendsOnline()) }); }); this is the function that converts it into an observable : onlineFriends.friend =

knockout.js Computed observable called twice in Internet Explorer

南笙酒味 提交于 2019-12-13 15:06:20
问题 Please see the simple example below; a text box that is bound to a computed observable. My problem is that IE calls the write method twice when the text box is updated. Firefox and other browsers do not appear to have this problem. I have observed this issue in IE 7 & 8. First of all, am I doing something wrong? If not, what is the recommended approach to deal with it? <script> var viewModel = { myTestVar: "aaa" }; viewModel.myTest = ko.computed({ read: function () { return viewModel

implementing html5 drag and drop photos with knockout js , durandal 2.0

最后都变了- 提交于 2019-12-13 14:49:07
问题 I have a list of photos in a knockout js viewmodel and I want to be able to swap among them(actually the more correct term is copy one on top of another). Here is my simplified viewmodel: define(['durandal/app', 'knockout', 'jquery'], function(app, ko, jquery) { var miscPhotos = ko.observableArray(); var draggedPhoto = ko.observable(); function handleDragStart(data, e) { // e.preventDefault(); draggedPhoto(data); console.log('dragStart'); return true; } function handleDragOver(e) { e

KnockoutJS - Print iteration index as input name

邮差的信 提交于 2019-12-13 14:41:28
问题 I am trying to create my first KnockoutJS form view in combination with Spring MVC's @ModelAttribute binding. Data is loaded over Ajax and populated with KnockoutJS Data is added over KnockoutJS Data is removed over Ajax and KnockoutJS Data will be saved with an normal POST submit to Spring MVC controller. To bind the form inputs to a Spring MVC controller, I need the iteration index from KnockoutJS. So I tried following: But the values from my database are never bound like they are when I am

Make Knockout applyBindings to treat select options as number

跟風遠走 提交于 2019-12-13 14:23:58
问题 Im using Knockout in combination with html select / option (see Fiddle): <select data-bind="value: Width"> <option>10</option> <option>100</option> </select> When calling applyBindings this options are treated as strings. This leads to unwanted effects. Consider the following Sample: function AreaViewModel() { var self = this; self.Width = ko.observable(10); self.Height = ko.observable(10); self.Area = ko.computed(function () { return self.Width() * self.Height(); }); } $(document).ready

Knockout accordion bindings break

你。 提交于 2019-12-13 14:17:33
问题 The following binding worked prior to 1.9: ko.bindingHandlers.accordion = { init: function(element, valueAccessor) { var options = valueAccessor() || {}; setTimeout(function() { $(element).accordion(options); }, 0); ko.utils.domNodeDisposal.addDisposeCallback(element, function(){ $(element).accordion("destroy"); }); }, update: function(element, valueAccessor) { var options = valueAccessor() || {}; $(element).accordion("destroy").accordion(options); } } But since 1.9, it no longer works, and

knockout checked binding - only one checked

六眼飞鱼酱① 提交于 2019-12-13 13:45:04
问题 I have a list of Admins with a check box. I want to be able to select only one Admin. HTML: <tbody data-bind="foreach: people"> <tr> <td> <input type="checkbox" data-bind="attr: { value: id }, checked: $root.selectedAdmin"> <span data-bind="text: name"/> </td> </tr> </tbody JS: function Admin(id, name) { this.id = id; this.name = name; } var listOfAdmin = [ new Admin(10, 'Wendy'), new Admin(20, 'Rishi'), new Admin(30, 'Christian')]; var viewModel = { people: ko.observableArray(listOfAdmin),