 # EZ-Modal
 ###
 
-Template.bootstrap_magic_preview_popovers.rendered = ->
-  $('[data-toggle="popover"]').popover()
+Template.bootstrap_magic_preview_popovers.onRendered ->
+  this.$('[data-toggle="popover"]').popover()
 
-Template.bootstrap_magic_preview_tooltips.rendered = ->
+Template.bootstrap_magic_preview_tooltips.onRendered ->
   this.$('[data-toggle="tooltip"]').tooltip()

  subCatId = BootstrapMagic.dictionary.currentSubCategory.get()
  return _.find bootstrap_magic_variables, (group) -> group._id is subCatId

Template._bootstrap_magic.created = ->
  BootstrapMagic.start() if BootstrapMagic.start

Template._bootstrap_magic.rendered = ->
  BootstrapMagic.dictionary.currentCategory.set bootstrap_magic_variables[0].category
  BootstrapMagic.dictionary.currentSubCategory.set bootstrap_magic_variables[0]._id


# default starting script: load hard-coded defaults
# this function can be overriden by other packages for integrations

# Colorpicker Create/Destroy
###

Template.bootstrap_magic_input_color.onRendered ->
  thisColorPicker = $(@firstNode)
  .colorpicker horizontal: true
  .on 'showPicker', ->
