Questions tagged [bindinghandlers]

26 questions
10
votes
3 answers

Custom Binding Handlers With Knockout and RequireJS

I'm having an issue applying custom binding handlers when using knockout with requireJS. Basically, in the past I've included a global binding-handler js file that contains all my custom bindings. Now that I'm using requireJS to enforce…
Tui Popenoe
  • 2,098
  • 2
  • 23
  • 44
4
votes
2 answers

Knockoutjs foreach custom bindinghandler with afterAdd

I would like to build a custom bindingHandler ko.bindingHandlers.foreachWithHighlight that has an highlight effect when afterAdd. From documentation yellowFadeIn: function(element, index, data) { $(element).filter("li") …
user1199595
  • 406
  • 2
  • 7
  • 16
3
votes
1 answer

With custom binding for Masonry how would I resize the container appropriately

Based on the suggestion give here, and the information given here on how to make a custom bindingHandler for a forEach, I decided to attempt to write my own custom binding for a forEach and Masonry. Because the elements are added on the fly the…
BigDubb
  • 478
  • 7
  • 19
2
votes
1 answer

Unit Testing Knockout Binding Handlers with Jasmine

I have created a binding handler dependent on moment which is used for formatting the date. I wanted to unit test this binding handler using Jasmine. Below is my binding handler code: define(['knockout', 'moment'], function (ko, moment) { 'use…
2
votes
2 answers

How to call Knockout bindingHandler->Update after DOM is updated

I'm using jquery accordion in a KO bindingHandler, I have to populate the DOM, used by accordion UI, using ajax by an app requirement. this.faqList = ko.observableArray(); $.ajax({ url: 'getFaqs' }).done(function( data ) { …
opaucara
  • 41
  • 2
  • 7
2
votes
1 answer

knockout js fade transition binding handler when image src binding changes

if I have the following simple js/knockout code: .js (viewModel): var image = ko.observable('http://placehold.it/300x150'); view: How do I create a ko binding handler that will perform a simple cross-fade…
Rob
  • 10,004
  • 5
  • 61
  • 91
2
votes
1 answer

Updating the model does not update the view

I'm using what I believe to be the generally accepted ko.bindingHandler.select2: ko.bindingHandlers.select2 = { init: function (element, valueAccessor) { $(element).select2(valueAccessor()); …
Justin
  • 10,667
  • 15
  • 58
  • 79
1
vote
2 answers

Trigger Knockout BindingHandler linked to KnockoutObservable on document.body.scrollTop

I am attempting to trigger a Knockout BindingHandler as a direct result of the document.body.scrolltop value being greater or equal to a particular value. I have attempted to create an observable based on a statement. Firstly, is this possible? Or…
Hicki
  • 167
  • 1
  • 11
1
vote
0 answers

KnockoutJs BindingHandlers cancels validation

i'm using knockout.js and adding a BindingHandlers to format an observable to decimal. The thing is that when i applied this binding the required validationmessage is not appearing. This is the code function formatWithComma(x, precision, seperator)…
ZeVaZ
  • 11
  • 2
1
vote
1 answer

Knockout custom binding handler does not update children elements

I'm having a problem with a custom knockout binding handler that creates a context. The demonstration is here: http://jsfiddle.net/gf3tfarz/14/ When 'container' is applied to an observable array, it's not updating the children elements.
1
vote
1 answer

medium-editor custom binding

ko.bindingHandlers.editor = { init: function (element, valueAccessor, allBindingsAccessor) { var initialValue = ko.unwrap(valueAccessor); var options = allBindingsAccessor().editoroptions || {}; var…
Rati_Ge
  • 1,262
  • 2
  • 15
  • 37
1
vote
1 answer

Interpolation a missing item into an array bound to ko.bindingHandlers.options

I have the following scenario. Exemplary JavaScript: function Foo() { this.id = ko.observable("KEY_1"); //Current selected item this.list = [{ id: "KEY_2", text: "Two" }, { id: "KEY_3", text: "Three" }]; //All available…
philipooo
  • 1,039
  • 9
  • 17
1
vote
0 answers

viewModel and bindingContext are undefined in my bindingHandlers

I have the following bindingHandlers: ko.bindingHandlers.dateRW = { init: function (element, valueAccessor, allBindings, viewModel, bindingContext) { ko.utils.registerEventHandler(element, "change", function () { var value =…
Bronzato
  • 9,438
  • 29
  • 120
  • 212
1
vote
1 answer

Observables initialized/attached to Observable in extender not initialized at page load

I I have created a text counter to tell the user how many characters of they have typed and how many they have remaining available. This should show when the text area has focus and disappear then the text area loses focus. I have created a…
1
vote
1 answer

How do I wrap a css knockout binding with custom binding?

I am trying to create a custom binding which will encapsulate a series of css bindings. Specifically, instead of: data-bind="css: { success: PickInventoryViewModel.ajaxSuccess, fail: PickInventoryViewModel.ajaxFailure, working:…
Vinney Kelly
  • 4,975
  • 1
  • 25
  • 31
1
2