Skip to content

Instantly share code, notes, and snippets.

@chrismccord
Last active December 17, 2015 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrismccord/5519310 to your computer and use it in GitHub Desktop.
Save chrismccord/5519310 to your computer and use it in GitHub Desktop.
"I have a table that shows the 10 most recent entries and then via Sync new ones get added. Is there an easy way to remove existing entries to keep the total at 10?"
# Assuming your partial is named 'list_row' and your model is 'Todo'
class Sync.TodoListRow extends Sync.View
maxRows: 10
afterInsert: ->
$rows = @$el.siblings("tr")
$rows.first().remove() if $rows.length > @maxRows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment