             if @selectedByDefault is true 
                 @$list.find(".item.selected").trigger "deselect", silent: true
                 @selectedByDefault = false
-                @collection.trigger "deselected"
+                @collection?.trigger "deselected"
             else
                 @$list.find(".item:not(.selected)").trigger "select", silent: true
                 @selectedByDefault = true
-                @collection.trigger "selected"
+                @collection?.trigger "selected"
 
         invertSelected : ->
             toSelect = @$list.find(":not(.item.selected)")

            
            super options

            if @collection?
                @collection.on "selected deselected reset", @checkRequirements, this
                @view.on "keypressed", @keypressedOnView, this if @hotkey?

            @checkRequirements()
    
  
        checkRequirements: ->
            enable = @allowed()

            @$el.toggleClass "minimized", 100

        sortBy : (field, old_field) ->

            return unless @collection?

            re = new RegExp(" (#{_.values(@sortArrows).join("|")})$|$")
            dir = @collection.sortingDirection[field] ? 1
