knockout.js

Combining Knockout.js + KendoUI - What has been your experience?

僤鯓⒐⒋嵵緔 提交于 2019-12-21 12:33:15
问题 So I see that KendoUI has included an example of integration with Knockout.js: http://demos.kendoui.com/web/integration/index.html However, this looks like a pretty trivial example. According to this post, it looks like binding to something like Kendo's grid would be much more involved: http://www.kendoui.com/forums/ui/grid/knockoutjs-example-for-grid.aspx It also looks as if they are creating their own MVVM implementation to try and solve the issues. Has anyone here used KendoUI and Knockout

How do I find the intersection of an array of arrays that contain objects using Javascript/underscorejs?

孤者浪人 提交于 2019-12-21 12:29:15
问题 I can't figure out how to find the intersection of this set of arrays: [ [ {"name":"product1","light":"1"}, {"name":"product2","light":"2"}, {"name":"product5","light":"5"}, {"name":"product4","light":"4"} ], [ {"name":"product2","light":"2"}, {"name":"product3","light":"3"}, {"name":"product4","light":"4"} ],[...more arrays with objects] ] This is just sample data , the real set I have changes a lot but with that structure. I want the returned intersection to look like this (a single array

Jquery knockout: Render template in-memory

微笑、不失礼 提交于 2019-12-21 12:27:53
问题 I have a knockout template: <script id="draggableHelper" type="text/x-jquery-tmpl"> <div class="draggableHelper"> <span data-bind="text: Name"></span> </div> </script> Is possible to generate the result of the template, and save it into memory, by sending the object to populate the template? Something like: var result = ko.renderTemplate($("#draggableHelper").html(), { Name: "Test" }); 回答1: Yes it's possible to apply bindings to nodes unattached to the DOM. Just use very useful function ko

Knockout.js binding with multiple Select2

人走茶凉 提交于 2019-12-21 12:18:31
问题 My Question is when ever I bind my Select2 with Multiple with Knockout View Model. After selecting one of the options, the data is lost for the second time KnockOutCode $(window).load(function () { ko.bindingHandlers.select2 = { init: function (element, valueAccessor, allBindingsAccessor) { var obj = valueAccessor(), allBindings = allBindingsAccessor(), lookupKey = allBindings.lookupKey; $(element).select2(obj); if (lookupKey) { var value = ko.utils.unwrapObservable(allBindings.value); $

How to order knockout bindings?

淺唱寂寞╮ 提交于 2019-12-21 12:08:12
问题 I am using knockout.js. I am stuck in a little bit strange situation ( its hard to explain but i am trying, sorry if i am not clear ). I am using custom binding and options binding on a single select-list : <select data-bind="options : arrayOfOptions, optionsText: 'Name', optionsValue: 'Name', chosen: { }"> </select> ko.bindingHandlers.chosen = { init: function (element, valueAccessor, allBindingAccessor, viewModel, bindigContext) { var options = ko.utils.unwrapObservable(valueAccessor() || {

Passing params to children components in Knockout

眉间皱痕 提交于 2019-12-21 09:36:26
问题 I have a template: <template id="item-list"> <form action="" data-bind="submit: addItem"> <input type="text" name="addItem" data-bind="value: newItem"> <button type="submit">Add Item</button> </form> <ul class="item-list" data-bind="foreach: items"> <item params="title: title, $element: $element, $data: $data, $parent: $parent"></item> </ul> </template> <template id="item"> <li class="item" data-bind="text: title, click: $parent.removeItem"></li> </template> <item-list params="items: items"><

MVC4 - Is there a way to route the root to a “normal” unprocessed html page?

我是研究僧i 提交于 2019-12-21 07:56:16
问题 I have an MVC4 app, but I'm primarily using it for the WebAPI parts. I want to have a "plain old HTML" file sent back to the user (which will then use KnockoutJS or KendoUI to pull JSON from the webapi controllers). I know I can do this: routes.IgnoreRoute("{page}.html"); And then if I browse to "localhost/index.html" it does successfully just return my .html page. However, I really want to map the "root" default path "localhost/" to return my index.html. I tried this: routes.MapPageRoute(

Jquery selector to find out count of non empty inputs

半腔热情 提交于 2019-12-21 07:55:01
问题 I have the below HTML DOM <div id="container> <p data-bind="visible:ShowPostCode()"> <label class="field-label" for="postcode">Postcode</label> <input id="txtPostCode" data-bind="value:PostCode, valueUpdate: "afterkeydown"" class="field-stretch" type="text"> </p> <p data-bind="visible:ShowDateOfBirth()"> <label class="field-label" for="dateofbirth">Date of birth</label> <input data-bind="value:DateOfBirth, valueUpdate: "afterkeydown"" class="field-stretch" type="text"> </p> <p style="display:

Changing css class in knockout.js on mouse click

99封情书 提交于 2019-12-21 07:27:29
问题 The knockout.js documentation shows the css binding like this: <div data-bind="css: { profitWarning: currentProfit() < 0 }"> Profit Information </div> I need to adapt it to change the css class on mouseclick. How can I do this? Based on answers below, I am using some code like this: // CSS class to be applied <style> .bigclass { width: 200px; } </style> // Select list inside a jquery .tmpl <script id='criteriaRowTemplate' type='text/html'> <tr> <td> <select data-bind='click: makeBig, css:

Prevent a double click on a button with knockout.js

别等时光非礼了梦想. 提交于 2019-12-21 07:24:26
问题 What is the best way to disable a button so a double click doesn't occur with knockout.js. I have some users doing some quick clicking causing multiple ajax requests. I assume knockout.js can handle this in several ways and wanted to see some of the alternatives out there. 回答1: Use a semaphore (spinning lock). Basically, you count how many clicks an element has registered and if it is more than 1 you return false and don't allow the following clicks. A timeout function could be used to clear