knockout.js

Can cleanNode() be used to clean binding?

≡放荡痞女 提交于 2019-12-17 02:49:22
问题 With below code, input#p_in will be updated with the change of input#s_in. But I have used cleanNode(sec). Could anyone help understand why the binding is not cleared. <input id="p_in" data-bind="value: name"></input> <input id="s_in" data-bind="value: name"></input> <input id="cb" type="checkbox">same</input> <script type="text/javascript"> function AddrDataSet (name) { this.name = ko.observable(name); }; var primary_set = new AddrDataSet('p'); var sec_set = new AddrDataSet('s'); var pri = $

jQuery UI datepicker change event not caught by KnockoutJS

为君一笑 提交于 2019-12-16 20:03:59
问题 I'm trying to use KnockoutJS with jQuery UI. I have an input element with a datepicker attached. I'm currently running knockout.debug.1.2.1.js and it seems that the change event is never being caught by Knockout. The element looks like this: <input type="text" class="date" data-bind="value: RedemptionExpiration"/> I've even tried changing the valueUpdate event type but to no avail. It seems like Chrome causes a focus event just before it changes the value, but IE doesn't. Is there some

utilizing beforeMove/afterMove without a binding?

拈花ヽ惹草 提交于 2019-12-14 04:27:11
问题 I need to detect when items are moved in an observableArray. In my current version (2.1.0) I accomplish this by calling setTimeout on all delete events and waiting to see if an add event follows immediately on its heels: var delayed = []; var key; /* obtained by comparing original observableArray with updated list and iterating all differences */ if( /** record exists in original list but not new list ) { // it was deleted, we don't immediately fire a notification (it may get re-inserted in a

Knock out visible binding of anchor tag is not working

半世苍凉 提交于 2019-12-14 04:26:32
问题 I am using JavaScript module pattern in my application. Here is my html binding <a href="#" data-bind="visible:master.child.showDeleteLink,click: function(obj, event) { master.child.showDeletePopup() } "> My view modal is master.child=(function (my, jQuery, ko) { var textTemp; my.ViewModel = function () { self.showDeleteLink = ko.observable(); self.showDeleteLink = function () { if (textTemp.length > 500) return true; else return false; } ko.applyBindings(my.anothermodule); } }(master.child,

KnockoutOut JS - why are these values not binding correctly?

别说谁变了你拦得住时间么 提交于 2019-12-14 04:26:07
问题 I have this knockout observable array and I am trying to bind some of its values to my view. Where I am having difficulties is because its nested. I am not sure what the correct data-bind syntax is. This is my observable array data: I want to bind advertiserName within advertiser. This is my HTML <table id="tblBrand"> <thead> <tr> <th>Brand Name</th> <th> <button data-bind='click: $root.addBrand'>Add Brand</button></th> </tr> </thead> <tbody data-bind="foreach: brands"> <tr> <td> <input data

Knockout does not recognize manually click

浪子不回头ぞ 提交于 2019-12-14 04:25:49
问题 Here is sample http://jsfiddle.net/HhXGH/57/ I am clicking radio button by jquery but knockout.js does not recognize it.Still it shows first clicked value. <p>Send me spam: <input type="checkbox" data-bind="checked: wantsSpam" /></p> <div data-bind="visible: wantsSpam"> Preferred flavor of spam: <div><input type="radio" name="flavorGroup" value="cherry" data-bind="checked: spamFlavor" /> Cherry</div> <div><input type="radio" name="flavorGroup" value="almond" data-bind="checked: spamFlavor" />

Referencing properties of object constructor outside view model in knockout

早过忘川 提交于 2019-12-14 04:10:01
问题 So, I'm not entirely sure how to phrase this question as it's sort of two in one. I'm having a weird issue where I have an object constructor to create new 'projects' from an HTML form which are then pushed into an observableArray when the form is submitted. Everything works fine but to reference the related observables I have to use 'value: Project.title' or 'value: Project.whatever'. I haven't seen 'value: NameOfConstructor.property' used in any of the examples I've seen. I assume this

Specifying default sort in grid

白昼怎懂夜的黑 提交于 2019-12-14 03:52:33
问题 Is it possible to specify a default sort when using the knockout-kendo binding to bind the Telerik Kendo grid? I am binding the grid like this: kendoGrid: { data: grid.Rows, sortable: {allowUnsort: false,mode:'single'}, columns: grid.Columns} However, I have not found a way to specify the default sort. Standard Kendo has a sort:{field:"Col1",dir:"asc"} element that can be specified on the data source, but it's unclear how this can be applied to the kendoGrid binding Default Kendo sort element

Nested knockout template binding

情到浓时终转凉″ 提交于 2019-12-14 03:35:12
问题 $.ajax({ url: "/survey/surveyQuestions", success: function (questionsData) { $.ajax({ url: "/survey/surveyOptions", success: function (optionsData) { alert(questionsData.length); for (var i = 0; i < questionsData.length; i++) { QuestionsScript.Question = ko.mapping.fromJS(questionsData[i]); ko.applyBindings(QuestionsScript, document.getElementById("innerDiv")); for (var j = 0; j < optionsData.length; j++) { if (optionsData[j].QuestionId = questionsData.QuestionId[i]) { OptionsScript.Option =

Knockout : foreach data not display in HTML

喜你入骨 提交于 2019-12-14 03:29:24
问题 I want to display multi dimentional ko observable array data in html. But, i didn't get output. My code : <!-- ko if: ($parent.cust_opt_avail() === 1) --> <!-- ko foreach: $parent.customVal() --> <div class="product-custom-option-select"> <p class="options-label" data-bind="text:key"></p> <p class="options-label" data-bind="text:custom_option_select_text"></p> </div> <!-- /ko --> <!-- /ko --> cust_opt_avail() is ko observable variable. customVal is ko observable array. output of customVal is