Skip to content

Instantly share code, notes, and snippets.

@kubosho
Last active April 12, 2016 03:38
Show Gist options
  • Select an option

  • Save kubosho/4d53e59c73f6646eeeb73f12fd9cadc2 to your computer and use it in GitHub Desktop.

Select an option

Save kubosho/4d53e59c73f6646eeeb73f12fd9cadc2 to your computer and use it in GitHub Desktop.
Knockout preprocess for `attr: { src: "" }`
ko.bindingHandlers.attr.preprocess = function (value, name, addBinding) {
// value = { src:$data}
value = value.replace(/ /g, '');
var re = /{(src):(.*)}/;
var matchAttr = value.match(re);
if (matchAttr === null) {
return value;
}
// do something
return value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment