Hi, all.
I uploaded a plugin module for KO's binding overloading.
I have issues because i need to define new binding handler but has same binding name.
and i can solve it by giving different binding name, but it's very conflict during writing html code.
so, I write code for binding selector, that select one binding hander in many handlers have same binding name
Its idea is very simple.
binding handler add under same binding name and it should have a condition function.
before binding, plugin module search a binding handler that has matched condition and it's executed.
if you have any suggestion or anything, plz let me know.
below is sample code.
// sample binding overloading : check node type & alert
ko.bindingSelector.add(
"text",
{
"update": function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor() || {});
element.innerText = value + ": THIS is SPAN TAG";
}
},
function( element ) {
if ( element.tagName == "SPAN" )
return true;
return false;
}
);
ko.bindingSelector.add(
"text",
{
"update": function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor() || {});
element.innerText = value + ": THIS is DIV TAG";
}
},
function( element ) {
if ( element.tagName == "DIV" )
return true;
return false;
}
);