       @files = @options.files
 
       @$form = @$input.closest('form')
-      @$submit = @$form.find('input[type=submit]')
+      @$submit = @$form.find(@options.submit_selector ? 'input[type=submit]')
+      @$wrapper = @$input.closest(@options.wrapper_container_selector) if @options.wrapper_container_selector?
 
       @initFileUpload()
       @addFilesContainer()


      @$input.bind 'fileuploadalways', (event) =>
        @$input.removeClass 'uploading'
        @$form.removeClass  'uploading'

        @checkMaximum()



    addFilesContainer: ->
      if @options.files_container_selector? and $(@options.files_container_selector).length > 0
        @$filesContainer = $(@options.files_container_selector)
      else
        @$filesContainer = $('<div class="attachinary_container">')
        @$input.after @$filesContainer

    redraw: ->
      @$filesContainer.empty()
