diff --git a/lib/binding.js b/lib/binding.js index 36d65cb..63700a0 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -44,7 +44,12 @@ o_O.bindElementToRule = function(el, attr, expr, context) { return $(el)[attr].call($(el), y) } - return o_O.bindings[attr].call(context, y, $(el)) + var binding = o_O.bindings[attr]ยท + if(binding != null && binding != 'undefined') { + return binding.call(context, y, $(el)) + } else { + o_O.bindings.attr.call(context, {key: attr, value: y}, $(el)) + } }) } diff --git a/lib/bindings.js b/lib/bindings.js index 2168e2f..8c8631e 100644 --- a/lib/bindings.js +++ b/lib/bindings.js @@ -20,6 +20,14 @@ o_O.bindings['class'] = function(klass, $el) { $el.attr('class', klass) } +/* generic attribute binding + * usage: bind='href: myUrl()' + */ + +o_O.bindings['attr'] = function(attr, $el) { + $el.attr(attr.key, attr.value) +} + /* Two-way binding to a form element * usage: bind='value: myProperty' * special cases for checkbox