       order ?= "asc"
       @sort = sort
       @order = order
-      @get("#{@options.url}?sort=#{sort}&order=#{order}")
-    
+      @get("#{@options.url}?sort=#{sort}&order=#{order}&q=#{@query}")
+      
     update: () =>
       @body.fadeTo('fast', 0.2)
       $.ajax
-        url: "#{@options.url}?sort=#{@sort}&order=#{@order}"
+        url: "#{@options.url}?sort=#{@sort}&order=#{@order}&q=#{@query}"
         dataType: "html"
         success: @display
 

        @display(event.state.html)
        $.each $.headers, (i, header) =>
          header.check()
        

  class SortLink
    constructor: (element, table) ->

    constructor: (element, opts) ->
      @table = $(element)
      @body = @table.find('tbody')
      @search = $('input#q')
      
      @options = $.extend {}, opts
      @options.url ?= @body.attr("data-url") ? "/documents.js"
      @options.sort ?= @table.attr("data-sort") ? "created"
      @options.order ?= @table.attr("data-order") ? "desc"

      @sort = $.params("sort") ? @options.sort
      @order = $.params("order") ? @options.order
      @query = null
      
      @headers = @table.find('th a.sorter')
      $.each @headers, (i, header) =>
        header = new SortLink header, @
        $.headers.push header
      
      @activate()
      @table.bind "refresh", @update
      @search.bind "keyup", @setQuery
      
      @_original_content = @body.children()
      if Modernizr.history
        $(window).bind 'popstate', @restoreState
    
