           .hideAllContentDisplays contentDisplay
         contentDisplay.emit 'handleQuery', query
       else if state?
-        @openContent name, section, state, route, query
+        @openContent name, section, models, route, query
       else
         @loadContent name, section, slug, route, query
 

        else                      "#{model.title}#{getSectionName model}"
    , maxLength: 100) # max char length of the title

  openContent:(name, section, state, route, query)->
    KD.getSingleton("appManager").tell section, 'createContentDisplay', state,
      (contentDisplay)=>
        @openRoutes[route] = contentDisplay
        @openRoutesById[contentDisplay.id] = route
        contentDisplay.emit 'handleQuery', query

  loadContent:(name, section, slug, route, query)->
    routeWithoutParams = route.split('?')[0]
    KD.remote.api.JName.one {name: routeWithoutParams}, (err, name)=>
      if err
        new KDNotificationView title: err?.message or 'An unknown error has occured.'
      else if name?
        models = []
        name.slugs.forEach (slug, i)=>
          {constructorName, usedAsPath} = slug
          selector = {}
          konstructor = KD.remote.api[constructorName]
          selector[usedAsPath] = slug.slug
          konstructor?.one selector, (err, model)=>
            error err if err?
            unless model
              @handleNotFound route
            else
              models[i] = model
              if models.length is name.slugs.length
                @openContent name, section, models, routeWithoutParams, query
      else
        @handleNotFound route

  createContentDisplayHandler:(section)->
    ({params:{name, slug}, query}, state, route)=>
      route = name unless route
      contentDisplay = @openRoutes[route.split('?')[0]]
      if contentDisplay?


  handleRoute:(route, options={})->
    {entryPoint} = options
    if entryPoint?.slug? and entryPoint.type is "group"
      entrySlug = "/" + entryPoint.slug
      # if incoming route is prefixed with groupname or entrySlug is the route
      # also we dont want koding as group name
      if not ///^#{entrySlug}///.test(route) and entrySlug isnt '/koding'
        route =  entrySlug + route

