Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- YUI().use('model', 'model-list', function (Y) {
- Y.Tag = Y.Base.create('tag', Y.Model, [], {}, {
- ATTRS: {
- name: {}
- }
- });
- Y.Tags = Y.Base.create('tags', Y.ModelList, [], { model: Y.Tag });
- Y.Post = Y.Base.create('post', Y.Model, [], {
- _setTags: function (tags) {
- // Make sure we just have a native Array of Tag instances.
- tags = Y.Array(tags instanceof Y.ModelList ? tags.toArray() : tags);
- // Update the Tags instance with the new tags.
- this.get('tags').reset(tags);
- }
- }, {
- ATTRS: {
- title: {},
- body : {},
- tags : {
- value : new Y.Tags,
- setter: '_setTags'
- }
- }
- });
- var post = new Y.Post({
- title: 'Foo Post',
- body : 'Bla bla bla…',
- tags : [
- { name: 'YUI' },
- { name: 'App Framework' }
- ]
- });
- post.get('tags').add({ name: 'JavaScript' });
- });
Add Comment
Please, Sign In to add comment