-# Modified from e2c7296822952f9dcb4b7d3a39e16cca7b5dd462
-# Add require 'jquery'
+# Modified from 98bd6cf5f62e596bb6bfcff8e2dcea07ce007de4 -- add require `jquery`
 $ = jQuery = require('jquery')
 
 elements =


# Trigger attach event when views are added to the DOM
triggerAttachEvent = (element) ->
  if element.attr?('triggerAttachEvents') and element.parents('html').length
    element.find('[triggerAttachEvents]').add(element).trigger('attach')

for methodName in ['append', 'prepend', 'after', 'before']
  do (methodName) ->
    originalMethod = $.fn[methodName]
    jQuery.fn[methodName] = (args...) ->
      result = originalMethod.apply(this, args)
      triggerAttachEvent(args[0])
      result

for methodName in ['prependTo', 'appendTo', 'insertAfter', 'insertBefore']

  wireOutlets: (view) ->
    @find('[outlet]').each ->
      element = $(this)
      outlet = element.attr('outlet')
      view[outlet] = element
      element.attr('outlet', null)

  bindEventHandlers: (view) ->
    for eventName in events
