           $(".#{data.single}-search").addClass("hide")
           $(".#{data.single}-search-query").attr("value","")
         return false
-=======
-    navEvents[templateEvent] = (event, template) ->
-      context = template.data
-      single = context.single
-      value = event.target.value
-      $(".#{data.single}-search").removeClass("hide")
-      if value?
-        if value.has("=")
-          key = value.split("=")[0]
-          search_string = value.split("=")[1]
-          search = {}
-          search[key] = 
-            $regex: ".*#{search_string}.*"
-            $options: "i"
-          Session.set("#{data.single}Find", search)
-        else if value.has(" ")
-          search_terms = value.split " "
-          regex_array = 
-            for term in search_terms
-               ".*#{term}.*"
-          regex = regex_array.join "|"
-          Session.set("#{data.single}Find", {name: {$regex: regex, $options: "i"}})
-        else
-          regex = ".*#{value}.*"
-          Session.set("#{data.single}Find", {name: {$regex: regex, $options: "i"}})
-      else
-        Session.set("#{data.single}Find", {})
-        $(".#{data.single}-search").addClass("hide")
-        $(".#{data.single}-search-query").attr("value","")
-      return false
->>>>>>> 2d6d00a2da830ee8d011084d970a22eed0949f7f
 
     if data.nav?.events?
       _.extend(data.nav.events, navEvents)

        $(".#{single}-search-query").attr('value','')
        Session.set("#{single}Find",{})
        return false
=======
    navEvents[templateEvent] = (event, template) ->
      context = template.data
      single = context.single
      klass = context.klass
      console.log "You have not defined a custom add handler for #{data.title}.  Using the default."
      if typeof context.newItemCallback isnt 'undefined'
        _id = context.newItemCallback()
      else
        _id = klass.insert()
 
      # Show the edit form after a 100ms delay after the item is inserted .
      showForm = () ->
        $("##{_id}").removeClass('hidden')

      setTimeout showForm, 100, _id

      return false  
    # ---------------------------------------------------------------------------------------

    templateEvent = "click .purge-disabled-#{data.plural}"
    navEvents[templateEvent] = (event, template) ->
      context = template.data
      plural = context.plural
      console.log "You have not defined a custom purge handler for #{data.title}.  Using the default."
      confirm_dialog = """
      Are you sure you want to purge the diabled #{plural}?
      <br><br>
      <div class='alert alert-error'>
        <h4>Severe Warning</h4>
        All purged #{plural} cannot be recovered.  This will be your ONLY warning.
      </div>
      """

      bootbox.confirm confirm_dialog, (confirmed) ->
        if confirmed
          Meteor.call "purge#{context.title}",
          (error, result) ->
            if error
              Meteor.Errors.throw error
            if result
              Meteor.Notices.throw('Your disabled records have been purged.', 'success')
      return false
    # ---------------------------------------------------------------------------------------

    templateEvent = "click .reset"
    navEvents[templateEvent] = (event, template) ->
      context = template.data
      single = context.single
      $(".#{single}-search").addClass('hide')
      $(".#{single}-search-query").attr('value','')
      Session.set("#{single}Find",{})
      return false
>>>>>>> 2d6d00a2da830ee8d011084d970a22eed0949f7f

    # ---------------------------------------------------------------------------------------
    # Search
    # At the moment the query for search uses name as the key.  Need to revist this
    # to make it so that the package user can set what the default
    templateEvent = "keyup .#{data.single}-search-query"
<<<<<<< HEAD
    if not DMUtils.find(Template.listNav._events, 'selector', ".#{data.single}-search-query")
      navEvents[templateEvent] = (event, template) ->
        context = template.data

        element.addClass('hidden')
        Session.set("edit-#{single}", null)
        return false

    # Add in or override user defined events.
    if data.list?.events?
