Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created August 10, 2016 20:38
Show Gist options
  • Save timurvafin/0743fa3a78bebb626fec37645582ecf5 to your computer and use it in GitHub Desktop.
Save timurvafin/0743fa3a78bebb626fec37645582ecf5 to your computer and use it in GitHub Desktop.
class CustomComponent
constructor: (@$el) ->
@dataKey = "custom-key"
@defaults = {}
@options = @_options(@$el)
_bindEvents: ->
@$el.on "click", ...
_options: ($el) ->
$.extend @defaults, $el.data(@dataKey)
new CustomComponent(el) for el in $("[data-custom-key]")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment