In each-*, use the iterate handler to walk to object, instead of doing
it directly. This required modifying the iterate handler to support objects in addition to arrays.
Showing
1 changed file
with
4 additions
and
2 deletions
... | @@ -314,8 +314,10 @@ getInputValue = (el) -> | ... | @@ -314,8 +314,10 @@ getInputValue = (el) -> |
314 | iterate = (collection, callback) -> | 314 | iterate = (collection, callback) -> |
315 | if Rivets.config.adapter.iterate | 315 | if Rivets.config.adapter.iterate |
316 | Rivets.config.adapter.iterate collection, callback | 316 | Rivets.config.adapter.iterate collection, callback |
317 | else | 317 | else if collection instanceof Array |
318 | callback(item, i) for item, i in collection | 318 | callback(item, i) for item, i in collection |
319 | else | ||
320 | callback(m, n) for n, m of collection | ||
319 | 321 | ||
320 | # Core binding routines. | 322 | # Core binding routines. |
321 | createInputBinder = (routine) -> | 323 | createInputBinder = (routine) -> |
... | @@ -397,7 +399,7 @@ Rivets.binders = | ... | @@ -397,7 +399,7 @@ Rivets.binders = |
397 | marker = @marker | 399 | marker = @marker |
398 | iterate collection, (item, i) => | 400 | iterate collection, (item, i) => |
399 | data = {} | 401 | data = {} |
400 | data[n] = m for n, m of @view.models | 402 | iterate @view.models, (item, i) => data[i] = item |
401 | data[@args[0]] = item | 403 | data[@args[0]] = item |
402 | data["#{@args[0]}_index"] = data['rivets_index'] = i | 404 | data["#{@args[0]}_index"] = data['rivets_index'] = i |
403 | itemEl = el.cloneNode true | 405 | itemEl = el.cloneNode true | ... | ... |
-
Please register or sign in to post a comment