Expose a register function to register new custom binding routines.
Showing
2 changed files
with
8 additions
and
1 deletions
... | @@ -76,6 +76,9 @@ | ... | @@ -76,6 +76,9 @@ |
76 | bidirectionals = ['value', 'checked', 'unchecked', 'selected', 'unselected']; | 76 | bidirectionals = ['value', 'checked', 'unchecked', 'selected', 'unselected']; |
77 | 77 | ||
78 | rivets = { | 78 | rivets = { |
79 | register: function(routine, routineFunction) { | ||
80 | return bindings[routine] = routineFunction; | ||
81 | }, | ||
79 | bind: function(el, adapter, contexts) { | 82 | bind: function(el, adapter, contexts) { |
80 | var attribute, context, keypath, node, path, type, _i, _len, _ref, _results; | 83 | var attribute, context, keypath, node, path, type, _i, _len, _ref, _results; |
81 | if (contexts == null) { | 84 | if (contexts == null) { | ... | ... |
... | @@ -65,8 +65,12 @@ bindings = | ... | @@ -65,8 +65,12 @@ bindings = |
65 | # to propogate those changes back to the model object. | 65 | # to propogate those changes back to the model object. |
66 | bidirectionals = ['value', 'checked', 'unchecked', 'selected', 'unselected'] | 66 | bidirectionals = ['value', 'checked', 'unchecked', 'selected', 'unselected'] |
67 | 67 | ||
68 | # The rivets module. Exposes a single `bind` function. | 68 | # The rivets module exposes `register` and `bind` functions to register new |
69 | # binding routines and bind contexts to DOM elements. | ||
69 | rivets = | 70 | rivets = |
71 | register: (routine, routineFunction) -> | ||
72 | bindings[routine] = routineFunction | ||
73 | |||
70 | bind: (el, adapter, contexts = {}) -> | 74 | bind: (el, adapter, contexts = {}) -> |
71 | for node in el.getElementsByTagName '*' | 75 | for node in el.getElementsByTagName '*' |
72 | for attribute in node.attributes | 76 | for attribute in node.attributes | ... | ... |
-
Please register or sign in to post a comment