Add a callout that can convert the cloned model in each-* back into
whatever real model the adapter wants.
Showing
1 changed file
with
7 additions
and
0 deletions
... | @@ -319,6 +319,12 @@ iterate = (collection, callback) -> | ... | @@ -319,6 +319,12 @@ iterate = (collection, callback) -> |
319 | else | 319 | else |
320 | callback(m, n) for n, m of collection | 320 | callback(m, n) for n, m of collection |
321 | 321 | ||
322 | convertToModel = (data) -> | ||
323 | if Rivets.config.adapter.convertToModel | ||
324 | Rivets.config.adapter.convertToModel(data) | ||
325 | else | ||
326 | data | ||
327 | |||
322 | # Core binding routines. | 328 | # Core binding routines. |
323 | createInputBinder = (routine) -> | 329 | createInputBinder = (routine) -> |
324 | publishes: true | 330 | publishes: true |
... | @@ -402,6 +408,7 @@ Rivets.binders = | ... | @@ -402,6 +408,7 @@ Rivets.binders = |
402 | iterate @view.models, (item, i) => data[i] = item | 408 | iterate @view.models, (item, i) => data[i] = item |
403 | data[@args[0]] = item | 409 | data[@args[0]] = item |
404 | data["#{@args[0]}_index"] = data['rivets_index'] = i | 410 | data["#{@args[0]}_index"] = data['rivets_index'] = i |
411 | data = convertToModel data | ||
405 | itemEl = el.cloneNode true | 412 | itemEl = el.cloneNode true |
406 | previous = if iterated.length > 0 | 413 | previous = if iterated.length > 0 |
407 | iterated[iterated.length - 1].els[0] | 414 | iterated[iterated.length - 1].els[0] | ... | ... |
-
Please register or sign in to post a comment