Skip to content

Instantly share code, notes, and snippets.

@mikeknoop mikeknoop/
Created Feb 23, 2012

What would you like to do?
Backbone Chrome Extension
($, _, Backbone, MustacheWrapper, InitTemplate) ->
ZapsView = Backbone.View.extend
Zaps view
'click a[data-action]': 'actionClick'
initialize: (options) ->
render: () ->
zapHtml: '<div>Hello World!</div>'
view =
zapHtml: zapHtml
@$el.html(Mustache.to_html(InitTemplate, view))
actionClick: (e) ->
# Callback handler for clicking an action item
action = $(e.currentTarget).attr('data-action')
zapId = $(e.currentTarget).attr('data-zap')
switch action
when 'run' then @run(zapId)
when 'pause' then @pause(zapId)
when 'unpause' then @unpause(zapId)
return false # cancel click
run: (id) ->
# Run the zap with the id specified
pause: (id) ->
# Puase the zap with the id specified
unpause: (id) ->
# Unpuase the zap with the id specified
unload: () ->
# This function called when the content view changes away from this view
return ZapsView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.