knockout.js

Prevent items to be 'droppable' in other (parent/child) elements

荒凉一梦 提交于 2019-12-30 11:01:28
问题 I use knockout-sortable.js to let the user drag and drop items to give them a different order, but I'm experiencing problems when I have multiple 'drop zones' on my page. I have nested sets, all of which are sortable, but not interchangeable. My code: <div class="sortable" data-bind="sortable: blueprint.pages"> <tr><td>Blabla</td></tr> </div> And at some other point: <div class="sortable" data-bind="sortable: selectedPage().page_sections"> <tr><td>Another blabla</td></tr> </div> I can now

Knockout Js with Jquery UI Datepicker - “Missing instance data for this datepicker”

老子叫甜甜 提交于 2019-12-30 10:41:31
问题 I have a date declared as an observable in my view model like this: self.date = ko.observable(date); In my markup, I am declaring the control like this: <div class="input-group"> <input class="form-control datepicker" data-bind=" datepicker: date, attr: { id: 'Payments_' + $index() + '_Date', name: 'Payments[' + $index() + '].Date' } " data-dateformat="dd/mm/yy" data-val="true" data-val-date="The field Date must be a date." data-val-required="The Date field is required." /> <span class="input

Knockout JS “uniqueName” binding - Same name to two fields

回眸只為那壹抹淺笑 提交于 2019-12-30 10:25:11
问题 I am using Knockout JS to create an editor. I am using the foreach property to loop around a list in my model. <tbody data-bind='foreach: Properties'> I am using JQuery unobtrusive validation whichneeds a name property to validate. I want to assign the same name to two fields, in order to be able to output a validation message. Is it possible to use the same uniqueName property on two fields? <tr> <td> <input data-bind='value: type, uniqueName: true' data-val = "true", data-val-required =

Knockout nested objects and parentheses

↘锁芯ラ 提交于 2019-12-30 09:06:10
问题 Few things I don't get. According to KO documentation (and many posts here on SO), parentheses should be used when querying and writing observables. But when binding sub-properties it seems to me that it doesn't matter if you use parentheses or not. <span data-bind="text: selectedMessage() && selectedMessage().message().subject()"></span> <span data-bind="text: selectedMessage() && selectedMessage().message().subject"></span> = both return correct value. Can anyone explain to me why this is?

Set a custom error message using the native rules of the knockout validation plugin

醉酒当歌 提交于 2019-12-30 07:54:12
问题 I am using Asp.net MVC3 and knockoutjs library. I need to do some client side validation. I am exploring the knockout validation plugin. So I declare the following ko.observable value in my js code: var numberValue = ko.observable().extend({ number: true }) This is my view part: <input data-bind = "value: numberValue " /> When the user enters some value that is not a number an error message is displayed : "Please enter a number". Can I display a different error message but still using the

Why does AngularJS execute function on every digest loop?

坚强是说给别人听的谎言 提交于 2019-12-30 07:21:11
问题 I'm coming from Knockout and I'm trying to understand how Angular updates the scope. I'm a bit confused as to why a function defined on the scope (e.g. $scope.doStuff = function() ) gets executed on every single scope refresh. Plnkr link: http://plnkr.co/edit/YnvOELGkRbHOovAWPIpF?p=preview For example: HTML <div ng-controller="one"> <input type="text" ng-model="a"> {{b()}} </div> JS angular.module('test', []) .controller('one', ['$scope', function ($scope) { $scope.a = 'one'; $scope.b =

Knockout issue with prototypical inheritance

我的梦境 提交于 2019-12-30 07:11:08
问题 I have an issue with Knockout where I prototype a user object where the observable properties of my object seem to be overwritten by the last occurrence. Therefore I cannot use the same object more than once otherwise it will be overwritten. Although this is hard to explain, see my fiddle. http://jsfiddle.net/RSEcj/1/ What am I doing wrong? (or is this a bug in Knockout?) How can I fix the problem. 回答1: Because observables are functions and not properties they are represented by a single

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

Passing variables between KnockoutJS and AngularJS

只愿长相守 提交于 2019-12-29 09:36:16
问题 I am using Knockout in my SPA dashboard creation. Its working good.But we need to add more and more complex things in our dashboard, so we planned to develop the remaining part of dashboard in Angular. My question is how can i pass variables from knockout to Angular. I tried using set and get methods, but it didn't helped me.. 3.So, i tried like this, i would like to set an attribute value in the ko function when, like this.. <li id="setMgmtEnv"> <a href='javascript:;' data-bind="click:

HTML Entities with Knockout

青春壹個敷衍的年華 提交于 2019-12-29 07:29:31
问题 How can I output HTML Entities in fields that are bound to a variable in the viewModel? I would like to display an HTML Entity like ← ( ← ) in a field bound to a span in the HTML. Unfortunately, the HTML is escaped, so the browser displays ← instead of the symbol. Fiddle with an example: http://jsfiddle.net/nwinkler/KES2j/ JavaScript: var data = { value : '←'}; var viewModel = { field: ko.mapping.fromJS(data) }; ko.applyBindings(viewModel); HTML: <p>HTML: ←</p> <p>Knockout: <span data-bind=