Created
September 16, 2009 06:12
-
-
Save quackingduck/187903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $item = $('.item').remove(). | |
methods({ | |
load: function(attribs) { | |
this.set(attribs); | |
this.e.trigger('item:loaded',this); | |
return this; | |
}, | |
set: function(attribs) { | |
this.id = attribs.id; | |
this.find('.content input').val(attribs.content); | |
return this; | |
} | |
}). | |
end(); | |
$('#items'). | |
find('> .add button'). | |
click(function() { $(this).tigger('items:new') }). | |
end(). | |
bind('items:new', function() { $(this).c().add() }). | |
methods({ | |
load: function(items) { | |
var self = this; | |
$.each(items, function() { self.add().load(this) }); | |
}, | |
add: function() { | |
return $item.cloneWithMethods().show().appendTo(this.e.find('.items')); | |
} | |
}); | |
$(document).bind('items:loaded', function(e, items) { | |
$('#items').c().load(items) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment