knockout.js

Knockout Validation async validators: Is this a bug or am I doing something wrong?

那年仲夏 提交于 2019-12-20 09:52:18
问题 I really like how Eric Barnard's knockout validation lib integrates with observables, allows grouping, & offers custom validator pluggability (including on-the-fly validators). There are a couple of places where it could be more UX flexible/friendly, but overall it's reasonably well-documented... except, imo, when it comes to async validators. I wrestled with this for a few hours today before doing a search and landing on this. I think I have the same issues/questions as the original author,

AngularJS example in backbone.js and/or knockout.js

会有一股神秘感。 提交于 2019-12-20 09:44:08
问题 I'm comparing these frameworks to do some calculations on the client side. I really liked the example on the AngularJS site. I was wondering if any of the backbone.js or knockout.js experts on the site would please recreate that example in their respective frameworks. Here is the JSFiddle for it. Code of the Fiddle: <table ng:init="invoice= {items:[{qty:10, description:'gadget', cost:9.95}]}"> <tr> <th>Qty</th> <th>Description</th> <th>Cost</th> <th>Total</th> <th></th> </tr> <tr ng:repeat=

loading a knockout.js observableArray() from .ajax() call

a 夏天 提交于 2019-12-20 09:37:14
问题 This puzzles me. It must be something small I'm not seeing. I'm trying to load a very simple observableArray in knockout with an ajax call. javascript // we bind the array to the view model property with an empty array. var data = []; var viewModel = { vendors: ko.observableArray(data) }; ko.applyBindings(viewModel); $(function () { // on this click event, we popular the observable array $('#load').click(function () { // WORKS. Html is updated appropriately. viewModel.vendors([{ "Id": "01" },

knockoutjs - bindings with parameters triggered on load

廉价感情. 提交于 2019-12-20 09:08:30
问题 I've been doing a lot of knockoutjs lately, and I came across a strange occurence. As you can see in this fiddle http://jsfiddle.net/hqXjv/ when you set up a binding to click: testMethod then the action fires when the button is clicked. As you can see in this fiddle http://jsfiddle.net/kxTzM/ when you setup the binding to click: testMethod('hi') the action fires both when the button is clicked and on page load (I'm guessing on applyBindings) Having a parameter isn't necessary to reproduce the

Knockoutjs computed passing parameters

淺唱寂寞╮ 提交于 2019-12-20 08:56:54
问题 I am wondering if it is possible with knockoutjs to pass arguments when binding. I am binding a list of checkboxes and would like to bind to a single computed observable in my viewmodel. In my viewmodel (based on parameter passed to the read function) I want to return true/false based on certain conditions. var myViewModel=function(){ this.myprop=ko.computed({read: function(){ //would like to receive an argument here to do my logic and return based on argument. } }); }; <input type="checkbox"

Trying to do color animation for TR by custom binding

强颜欢笑 提交于 2019-12-20 07:39:47
问题 I am trying to do color animation for TR by custom binding but things are not working as expected. I made some mistake because I am new in KnockoutJS. So please tell me in which area I need to fix in my code. The mistake is here AnimateRow : $parent.Hasfade() I have a property called Hasfade which I initialize with false but when rows get inserted or updated then I set true. Custom binding code ko.bindingHandlers.AnimateRow = { update: function (element, valueAccessor) { var value = ko.utils

Durundal Google Translate

心不动则不痛 提交于 2019-12-20 06:36:28
问题 How can I bind Google translate in Durundal Shell.js , shell.html? html <div id="google_translate_element"></div> script <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en', autoDisplay: false }, 'google_translate_element'); } 回答1: Durandal doesn't render script tags within views. To render them, you should use knockout

Knockout to get the Attribute Value onClick function

淺唱寂寞╮ 提交于 2019-12-20 06:29:53
问题 HTML View with attr Value 'Qref'. This is the HTML Code for bindling Currently i have hard coded the Qref Attribute vaue <!--ko if:$parent.Type == 2 --> <input type="checkbox" data-bind="attr:{id: $data.Id , Qref: '3177'} , click: $root.answerClick">   <span data-bind="text: $data.Text , attr:{id: $data.Id}"></span> <!--ko if:$data.InputType == "text" --> <input type="text"> <!-- /ko --> <!-- /ko --> This is the event for CLick.I am able to access the ID But not able to access the Qref Value

Pass string parameters into click binding while retaining default params in Knockoutjs

天大地大妈咪最大 提交于 2019-12-20 04:49:51
问题 I'd like to pass arguments in to functions called on click, while retaining the default args. The issue is in the Hops part. I tried to make the remove<this> functions more clean with: self.removeItem = function(item, name){ self[name].destroy(item); } and <a href="#" data-bind="click: function() { $root.removeItem($data, "hops") }, visible: $root.hops.countVisible() > 1">Delete</a> I have tried passing $data, event, "hops" also. I went based on Knockout.js - passing parameters but I want to

Adding a loading icon to Knockout javascript

六月ゝ 毕业季﹏ 提交于 2019-12-20 04:10:55
问题 I have created a very simple example of a data load using Knockout. What I want to do is to add a a loading icon to show while the data is loading. Can anybody tell me the correct syntax to use with my example below? <script type="text/javascript" src="@Url.Content("~/Scripts/knockout-2.1.0.js")"></script> <script type="text/javascript"> function QBRatingsViewModel() { var self = this; var baseUri = '@ViewBag.ApiUrl'; self.qbratings = ko.observableArray(); $.getJSON("/api/qbrating", self