mbest / knockout-freedom Goto Github PK
View Code? Open in Web Editor NEWFrees each binding from being updated by updates to its siblings.
Frees each binding from being updated by updates to its siblings.
Hi, I have a computed function with read and write.
now when I write to the computed function I wanted to apply some validation logic in the write part. if the validation fails, I don,t want it to be written to the computed function. also I don't want the subscription to happen which is already configured to the computed function.
please advice.
This plugin will solve knockout/knockout#321 without having to use a fork of Knockout. This plugin will be compatible with versions 2.1 (current) and 2.2 (upcoming) of Knockout.
I'm having trouble using this plugin with Knockout-Validation. I can provide examples if necessary. Any ideas?
Several of your other plugins are AMD-compatible; plans to add that to this one?
Hi,
1st requirement - I have designed a form which has two text input control. where both are mandatory. now when the user just tabs out without entering and the text box looses focus the error message should be displayed. I am using knockout-validation with custom rules written.
2nd requirement - on click of the submit button, for all the text input if the rule fails it should show error message.
currently I am using hasfocus with few rules written to it. it works, but in chrome/safari and firefox 22 it takes 2 tabs to come out of the text input.
please advice.
ko.bindingValueWrap
currently wraps the binding value using a psuedo-observable function. It may seem like ko.computed
would do the job just as well. That is actually true (mostly). The problem with using ko.computed
here is that it needs to be disposed when the element is removed, but there's currently no way to get the element in ko.bindingValueWrap
. This would change If/when knockout/knockout#474 is included in Knockout.
ko.bindingValueWrap
using ko.computed
and element:
ko.bindingValueWrap = function(element, valueAccessor, valueWriter) {
var valueFunction = ko.computed({
read: function() {
return ko.utils.unwrapObservable(valueAccessor());
},
write: function(valueToWrite) {
var value = valueAccessor();
if (ko.isObservable(value)) {
value(valueToWrite);
} else if (valueWriter) {
valueWriter(valueToWrite);
}
},
disposeWhenNodeIsRemoved: element
});
...
return valueFunction;
};
Here's a version that could work right now, but doesn't dispose the computed until it's updated:
ko.bindingValueWrap = function(valueAccessor, valueWriter) {
var valueFunction = ko.computed({
read: function() {
return ko.utils.unwrapObservable(valueAccessor());
},
write: function(valueToWrite) {
var value = valueAccessor();
if (ko.isObservable(value)) {
value(valueToWrite);
} else if (valueWriter) {
valueWriter(valueToWrite);
}
},
disposeWhen: function() {
return !valueFunction.getSubscriptionsCount();
}
});
...
return valueFunction;
};
I'm not sure whether this is an issue that's fixable or if it's something that obviously can't work, but I found some of my bindings are not working when both this and knockout-classBindingProvider are included. I realize I haven't provided any details, since I haven't narrowed it down.
If I understood this correctly the "knockout-freedom" behaviour is now the default behaviour in KO3. Is it true?
Otherwise: is this compatible with KO3?
Hi,
1st requirement - I have designed a form which has two text input control. where both are mandatory. now when the user just tabs out and the text box looses focus the error message should be displayed. I am using knockout-validation with custom rules written.
2nd requirement - on click of the submit button, for all the text input if the rule fails it should show error message.
currently I am using hasfocus with few rules written to it. it works, but in chrome/safari and firefox 22 it takes 2 tabs to come out of the text input.
please advice.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.