I am having a binding handler with simple logic inside where i will update the observable so it will update itself in view .
This i a sample case where everything works as expected
My View :
<input data-bind="value: name" />
<hr/>
<div data-bind="fadeInText: name"></div>
Code :
ko.bindingHandlers.fadeInText = {
update: function(element, valueAccessor) {
ko.bindingHandlers.text.update(element,valueAccessor);//text becoz its binded to div
}
};
Here I'm trying to do something like this(below) and i am stuck here updating a observable
My view :
<input data-bind="value: name" />
<hr/>
<input type="text" data-bind="fadeInText: name" />
<div data-bind="text:ko.toJSON($data)"></div>
Code:
ko.bindingHandlers.fadeInText = {
update: function(element, valueAccessor) {
var value = valueAccessor();
ko.bindingHandlers.value.update(element,valueAccessor);
$(element).change(function () {
value($(element).fadeInText('get'));
});
}
};
In this given scenario there are two textboxes when i update a value in textbox-1 then textbox-2 value is getting updated .
But when i try to update textbox-2 value nothing gets updated i feel so close but for now i can't crack this up .
Checked chrome console i see Uncaught TypeError: undefined is not a function
but fadeInText
is present in binding
Update :
I tried allBindingsAccessor().fadeInText()
i get the old value everytime not the new entered one .
Fiddler provided here
There is something with same way done but its working fiddler here.
Any help on this one is great .