custom-binding

Why is this event being handled twice in knockout?

非 Y 不嫁゛ 提交于 2020-01-06 08:15:30
问题 For some reason the below code makes the links' click event fire twice. I'm relatively new to knockout and I think I might have done my custom binding wrong. Can anyone tell me what I've done wrong? (Btw, the reason I didn't post a fiddle is that I can't include the mapping plugin from github on jsfiddle.) JS: ko.bindingHandlers.activityContent = { init: function(element, valueAccessor, allBindings, viewModel, bindingContext) { // This will be called when the binding is first applied to an

Bind knockout.js to a boolean JQuery Mobile flip switch toggle

我的未来我决定 提交于 2019-12-23 02:17:33
问题 i have a boolean value bound to a JQM flip switch toggle, but i'm not able to see it reacting to changes to the underlying observable. This is my true/false observable: ko.booleanObservable = function (initialValue) { var _actual = ko.observable(initialValue); var result = ko.computed({ read: function () { var readValue = _actual().toString(); return readValue; }, write: function (newValue) { var parsedValue = (newValue === "true"); _actual(parsedValue); } }); return result; }; Which is the

knockout valueUpdate not working with Pagedown?

拜拜、爱过 提交于 2019-12-22 09:22:47
问题 I have the following in my view: <textarea data-bind="value: content, valueUpdate: 'afterkeydown'"></textarea> Which when typing, behaves as I'd expect. But I'm using a WMD / Pagedown editor to click a button that adds content to the field, much like StackOverflow's post contents box when you're creating / updating a post. If I just click a button (to add asterisks or brackets etc) and don't type anything, the value never gets updated in the content observable. I do have a save button that I

MTOM Encoding and Custom binding

大兔子大兔子 提交于 2019-12-22 05:38:50
问题 How do I configure custom binding and MTOM encoding? I have a custom binding like given below, <customBinding> <binding name="stsBinding"> <security authenticationMode="UserNameOverTransport" requireDerivedKeys="false" keyEntropyMode="ServerEntropy" requireSecurityContextCancellation="false" requireSignatureConfirmation="false"> </security> <httpsTransport /> </binding> </customBinding> And my MTOM binding is like below, <basicHttpBinding> <binding name="HttpStreaming" maxReceivedMessageSize=

Calling the method provided in HTML in Knockout custom bindinghandler

心不动则不痛 提交于 2019-12-13 04:42:23
问题 I'm using both knockout.js and hammer.js in my current project. I created a custom binding handler for the 'tap' event in hammer.js (this should also work for other events such as hold or swipe). My problem is that in this binding handler, I want to call a method that I provide in the data-bind attribute in HTML. According to the knockout documentation, I found out that I should call valueAccessor(), but unfortunately, this doesn't do anything. I've created this Fiddle, which should give you

Knockout custom binding for bootstrap select not updating viewmodel “selectedCategories/selectedCategory”

a 夏天 提交于 2019-12-12 17:01:49
问题 I am creating a knockout js custom binding that will allow me to use data-binding with bootstrap multiselect. I need it to work for single <select> 's and also multiselects <select multiple="true"> . I am doing it in this jsfiddle I have got it so that both single and multiselects can show the dropdown options and as new categories are added with the button, they show on the multiselect dropdown. I also want to update the viewmodels selectedItems which are _selectedCategory for the single

Knockout custom binding not updating

江枫思渺然 提交于 2019-12-12 03:17:23
问题 Please check what I am doing wrong. The update part of my custom bindinghandler does not executes when I create a control in javascript. I have an Add function that create a row in a table. Controls that are bound to the custom binding does executes the update part but not controls that are subsequently added. HTML <div id="collapse-programHead" class="panel-collapse collapse"> <div class="panel-body"> <table class="cv"> <thead> <tr> <th>Programme</th> <th>Core Module Count</th> <th>Core SAQA

Knockout custom binding does not show initial viewModel data properly

房东的猫 提交于 2019-12-12 01:56:27
问题 I use a third-party plugin to make a table editable. So I need to create a custom binding for <td> so that any changes to the text caused by the plugin would trigger a view model update. But the custom binding does not show correct data, as opposed to the built-in 'text' binding. Did I do anything wrong? Please see: http://jsfiddle.net/VbeBA/5 HTML: <table id="table1" cellspacing="0" cellpadding="0" border="0"> <tr> <th style="width:150px">Product</th> <th>Price ($)</th> <th>Quantity</th> <th

Custom binding(?) that adds some standard Knockout bindings to child nodes

半城伤御伤魂 提交于 2019-12-10 22:25:48
问题 I want to implement using Knockout something easily reusable (probably, custom binding) that could apply mix of standard bindings: the foreach binding to a tbody node and another standard bindings ( visible and css ) to its tr child nodes. AFAIK, the best way it can be achieved is to write a custom binding. I want to use it like that: <table> <tbody data-bind="tableRows: { rows: unfilteredItems, filter: rowFilter }"> <tr data-bind="possibly, some hard coded bindings including visible and css

Knockoutjs: ScrollIntoViewTrigger

雨燕双飞 提交于 2019-12-09 03:38:15
问题 i recently struggled with a problem and although i solved it for me, i'm not sure whether there aren't better solutions out there, so I'd appreciate any comments. Problem. i wanted to create a 'ScrollIntoView' binding. Since scrolling an element into view, requires the DOM-Element, i wrote a custom binding, which i then wanted to explicitly trigger, whenever i pleased. I started with this code: ko.bindingHandlers.scrollTo = { update: function (element, valueAccessor, allBindings) { var _value