From cb401a153eb191b74f0a66601d8fcfd71b2cbb55 Mon Sep 17 00:00:00 2001 From: Jordan Humphreys Date: Thu, 21 Jul 2016 09:16:09 -0700 Subject: [PATCH] Update readme for append events. --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9b86a27f..aa8e26ec 100644 --- a/README.md +++ b/README.md @@ -160,10 +160,10 @@ document.getElementById('myElement').addEventListener('tribute-no-match', functi Some useful approaches to common roadblocks when implementing @mentions. ### Updating a collection with new data -You can update an instance of Tribute on the fly. If you have new data you want to insert into a collection you can access the collection values array directly: +You can update an instance of Tribute on the fly. If you have new data you want to insert into the current active collection you can access the collection values array directly: ```js -tribute.collection[0].values.push([ +tribute.appendCurrent([ {name: 'Howard Johnson', occupation: 'Panda Wrangler', age: 27}, {name: 'Fluffy Croutons', occupation: 'Crouton Fluffer', age: 32} ]); @@ -171,6 +171,17 @@ tribute.collection[0].values.push([ This would update the first configuration object in the collection array with new values. You can access and update any attribute on the collection in this way. +You can also append new values to an arbitrary collection by passing an index to `append`. + +```js +tribute.append(2, [ + {name: 'Howard Johnson', occupation: 'Panda Wrangler', age: 27}, + {name: 'Fluffy Croutons', occupation: 'Crouton Fluffer', age: 32} +]); +``` +This will append the new values to the third collection. + + ### Programmatically detecting an active Tribute dropdown If you need to know when Tribute is active you can access the `isActive` property of an instance. @@ -249,5 +260,3 @@ The major focus that we could use your help with is creating wrappers for differ * Ember component * Compatability with WYSIWYG editors (TinyMCE, etc) * Testing - -