knockout.js

Material Design Lite: How to programatically reset a floating label input text

ぐ巨炮叔叔 提交于 2020-01-06 02:44:16
问题 I am currently building a Single Page App with knockout.js and Material Design Lite. I have a form which allow creating (and persisting) a new entity. The first time the form is used, the floating label input works correctly. But after that, if I reset the values of the fields through knockout observables (i.e. set the field values to "" in order to be able enter the values for another new entity) the floating label doesn't reset: the floating label still floats above the field, while it

Subscribe to select item from foreach loop

 ̄綄美尐妖づ 提交于 2020-01-06 02:21:26
问题 I am using the foreach binding to generate a table and in each row there is a drop down list. Based on their selection I need to display additional columns. The issue I am having is I need to subscribe to this drop down list to let me table header know that it needs to display the additional column headers. How can I subscribe to the select list that is generated from a foreach loop of objects? 回答1: Here's a jsfiddle i slapped together to show you how it could work: http://jsfiddle.net/vzkaY

Animation before 'with' binding update

为君一笑 提交于 2020-01-05 16:55:33
问题 I'm using "with" binding and I would like to invoke some animation before change value, and after that. Does any body know how to do it? 回答1: You could always wrap the with binding with your own binding which uses jQuery for some animation like so: ko.bindingHandlers['fadingWith'] = { init: function(element, valueAccessor, allBindingsAccessor, context) { return ko.bindingHandlers['with']['init'](element, valueAccessor, allBindingsAccessor, context); }, update: function(element, valueAccessor,

How to use Checkbox inside Select options in Knockout

拜拜、爱过 提交于 2020-01-05 16:50:56
问题 Hi I want to add checkbox for all the options in dropdown. My HTML is like this - <div class="multi-select-dd-list"> <div id="checkboxes" class="patient-list-selection"> <select class="patient-list-select specialty-list-left" data-bind="options : specialtiesList, optionsText : 'name'"> </select> </div> </div> So here I am binding specialtiesList. What I want is a way to use checkbox before each option of the dropdown. Any suggestions? 回答1: Here's the code implementing the same. I think you

knockout js: The “with” binding breaks the jquery ui

二次信任 提交于 2020-01-05 15:17:10
问题 http://jsfiddle.net/AYPze/9/ In this example I have two similar divs with the same goal. Bind the selected date from the datetimepicker and save it to the object binded by knockout js. The problem with the first div is that the datetimepicker won't show up because i use the knockout "with" binding. The second div uses the normal knockout js binding syntax, which works fine with the datetimepicker. I experienced this behavior also with the jquery-ui Accordion My Questions: Is this a bug in

Remove an element from observableArray inside another observableArray in knockout

 ̄綄美尐妖づ 提交于 2020-01-05 12:08:21
问题 After finishing knockout tutorial working with lists and collections I decided to go a little bit further to implement two level nesting with knockout. The structure of my ViewModel looks like this: function ViewModel() { this.elements = ko.observableArray([{ id: 1, txt: 'first', el: ko.observableArray(['first', 'second']) },{ id: 2, txt: 'second', el: ko.observableArray(['first', 'third']) },{ id: 3, txt: 'third', el: ko.observableArray(['fourth', 'fifth']) }]); this.remove = function(el){

Under what conditions does a Knockout native template re-render

大憨熊 提交于 2020-01-05 11:02:25
问题 I have a complex knockout page that renders a template conditionally: <!-- ko template: {'if': $root.itemToEdit.SomeObject() === $data, name: 'EditItemTemplate', afterRender: $root.initializeEditPanel } --> <!-- /ko --> and the template: <script type="text/html" id="EditItemTemplate"> <div id="editContainer" class="fd_editContainer"> //.. lots of markup and knockout bindings ... <input class="checkbox" id="questionDisplayOptionOverride" type="checkbox" data-bind="checked: $data.AnObject()

How to bind the <ul> elements with new viewmodel data? - knockout.js

一个人想着一个人 提交于 2020-01-05 10:06:44
问题 I have a requirement where the view gets updated with new data. Here is the code for the view: <table> <thead id="resultTableHeader"> <tr style="text-align: center" data-bind="foreach: columns"> <th style="text-align: center; height: 23px;" data-bind="visible: checked, text: header"> </th> </tr> </thead> <tbody id="resultTableBody" data-bind="foreach: simpleSearchResultsArray"> <tr> <td style="text-align: center; vertical-align: middle;"> <span data-bind="text: $index()+1"></span> </td> <td

Function bound to click action in foreach not being called

放肆的年华 提交于 2020-01-05 09:47:49
问题 I'm having trouble binding my click action to the view model function to remove an item from an array (inside a foreach binding) I've got the following view model var FileGroupViewModel = function () { var self = this; self.files = ko.observableArray(); self.removeFile = function (item) { self.files.remove(item); } self.fileUpload = function (data, e) { var file = e.target.files[0]; self.files.push(file); }; } var ViewModel = function () { var self = this; self.FileGroup = ko.observableArray(

Function bound to click action in foreach not being called

筅森魡賤 提交于 2020-01-05 09:46:46
问题 I'm having trouble binding my click action to the view model function to remove an item from an array (inside a foreach binding) I've got the following view model var FileGroupViewModel = function () { var self = this; self.files = ko.observableArray(); self.removeFile = function (item) { self.files.remove(item); } self.fileUpload = function (data, e) { var file = e.target.files[0]; self.files.push(file); }; } var ViewModel = function () { var self = this; self.FileGroup = ko.observableArray(