1
0
Fork 0

Phi: allow setting of properties via hash

Defining the set of properties for the knockoutjs bridge via
array of array is clumsy, allow setting those via an object aka hash
is much easier.
This commit is contained in:
Torsten Dreyer 2015-11-19 12:00:16 +01:00
parent 0187820627
commit 7bfa20933b

View file

@ -162,9 +162,17 @@ define(['knockout'], function(ko) {
self.aliases = {};
self.setAliases = function(arg) {
arg.forEach(function(a) {
self.aliases[a[0]] = a[1];
});
if( Object.prototype.toString.call( arg ) === '[object Array]' ) {
// [
// [ shortcut, propertypath ],
// [ othercut, otherproperty ],
// ]
arg.forEach(function(a) {
self.aliases[a[0]] = a[1];
});
} else {
self.aliases = arg;
}
}
self.props = {};