Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Updated Attribute to work with watch
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanpalmer committed Aug 11, 2012
1 parent 5c530d1 commit c87506f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/spine.databind.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ class Attribute extends Template
keys: [ "attr" ]

bind: (operators,model,controller,el,options) ->
@init(operators,model,controller,el,options,"update")
if options.watch
for operator in operators
json = JSON.parse(operator.property)
for own property of json
@init([operator],model,controller,el,options,"update["+json[property]+"]")
else
@init(operators,model,controller,el,options,"update")

@update(operators,model,controller,el,options)

update: (operators,model,controller,el,options) ->
Expand All @@ -240,7 +247,9 @@ class Attribute extends Template
json = JSON.parse(operator.property)
for own property of json
value = binder.get(model,json[property])
el.attr(property,value)
if el.attr(property) isnt value
el.attr(property,value)
el.trigger("change")
@

class Checked extends Template
Expand Down
19 changes: 17 additions & 2 deletions src/spine.databind.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c87506f

Please sign in to comment.