Last active
December 11, 2015 17:48
-
-
Save VinSpee/4636551 to your computer and use it in GitHub Desktop.
coffee class fail: This should be a simple reusable toggler. it's defined in toggle.coffee and initiated in ui.coffee. The problem is this: @doToggle is begin called immediately upon init, it's not waiting for a click. any Ideas?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define ["jquery"], ($)-> | |
class Toggle | |
constructor: (context, toggle, toggler, togglable, callback) -> | |
@context = context | |
@$context = $(@context) | |
@$toggle = $(@context).find(toggle) | |
@$toggler = $(@context).find(toggler) | |
@$togglable = $(@context).find(togglable) | |
@callback = callback | |
@$toggler.on("click", (event) => @doToggle(@$togglable)) | |
doToggle:(togglable) -> | |
togglable.slideToggle -> | |
do @callback if @callback and typeof (@callback) is "function" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define ["toggler"], (Toggler)-> | |
initialize: -> | |
resultsToggler = new Toggler(".results", "[data-widget=toggle]", "[data-widget-component=toggler]", "[data-widget-component=togglable]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment