 
     # Generates html for new parameters
     # Copied from backend/app/assets/javascripts/admin/image_settings.js.erb
-    generateHTMLForParameters = (index) ->
+    generateHTMLForParameters = (name, index) ->
       "<div class='new_parameter_pairs row'>
         <div class='field'>
           <div class='five columns'>
             <label for='new_parameter_pairs_#{index}_name'>#{Spree.translations.name}</label>
             <input class='fullwidth new-parameter-name' id='new_parameter_pairs_#{index}_name'
-              name='new_parameter_pairs[#{index}][name]' type='text'><br>
+              name='new_parameter_pairs[#{index}][name]' type='text' value='#{name}'><br>
           </div>
 
           <div class='five columns'>

      $this.data("toggle-text", $this.text())
      $this.text(toggleText)
      $("#admin-response-headers-container").toggle("display")

    $("#endpoint_sample_message").change (e) ->
      message = messageSearch($(e.target).val())

    # Creates ACE editor for payload
    payloadEditor = createEditor("endpoint_message_payload_editor", "endpoint_message_payload")

    addParameterField = (->
      parameterFieldsIndex = $("#new-parameters .new_parameter_pairs").length

      return (name = "") ->
        parameterFieldsIndex++
        $("#new-parameters").append generateHTMLForParameters(name, parameterFieldsIndex)
        bindParametersAutoCompleteTo $("input.new-parameter-name:last")
    )()


    $(".add-new-parameter").click (e) ->
      e.preventDefault()
      addParameterField()

    $(document).on "click", ".destroy_new_parameter_pairs", (e) ->
      e.preventDefault()
