Only perform the initial bind for each-* bindings once. Unbinding does not resto…
…re the initial node or remove the marker so el.parentNode is going to be null the second time around. [Closes #165]
Showing
1 changed file
with
8 additions
and
7 deletions
... | @@ -370,13 +370,14 @@ Rivets.binders = | ... | @@ -370,13 +370,14 @@ Rivets.binders = |
370 | block: true | 370 | block: true |
371 | 371 | ||
372 | bind: (el) -> | 372 | bind: (el) -> |
373 | attr = ['data', @view.config.prefix, @type].join('-').replace '--', '-' | 373 | unless @marker? |
374 | @marker = document.createComment " rivets: #{@type} " | 374 | attr = ['data', @view.config.prefix, @type].join('-').replace '--', '-' |
375 | @iterated = [] | 375 | @marker = document.createComment " rivets: #{@type} " |
376 | 376 | @iterated = [] | |
377 | el.removeAttribute attr | 377 | |
378 | el.parentNode.insertBefore @marker, el | 378 | el.removeAttribute attr |
379 | el.parentNode.removeChild el | 379 | el.parentNode.insertBefore @marker, el |
380 | el.parentNode.removeChild el | ||
380 | 381 | ||
381 | unbind: (el) -> | 382 | unbind: (el) -> |
382 | view.unbind() for view in @iterated if @iterated? | 383 | view.unbind() for view in @iterated if @iterated? | ... | ... |
-
Please register or sign in to post a comment