<commit_before><%= fields_for :node do |f| %>
  <%= f.fields_for slot_name, component do |f| %>
  <%= f.hidden_field :_type %>
  <%= error_messages_for :object => component %>

  <script id="quicklink-template-<%= slot_name.parameterize %>" type="text/x-jquery-tmpl">
    <%= render :partial  => 'admin/components/quick_link',
               :locals => {
                 :component => component,
                 :slot_name  => slot_name,
                 :text => "",
                 :link => "",
                 :index => nil
               }
    %>
  </script>

  <p>
    <%= label_tag "node_#{slot_name}_title", "Title" %><br />
    <span class="input-wrap"><%= text_field_tag "node[#{slot_name}][title]", component.title, :id => "node_#{slot_name}_title" %></span>
  </p>

  <div id="quicklinks-<%= slot_name.parameterize %>">

    <% component.quick_links.each_with_index do |quicklink, index| %>
      <%= render :partial  => 'admin/components/quick_link',
                 :locals => {
                   :component => component,
                   :slot_name  => slot_name,
                   :text => quicklink.link_text,
                   :link => quicklink.link,
                   :index => nil
                 }
      %>
    <% end %>

    <% if component.quick_links.empty? %>
      <%= render :partial  => 'admin/components/quick_link',
                 :locals => {
                   :component => component,
                   :slot_name  => slot_name,
                   :text => "",
                   :link => "",
                   :index => nil
                 }
      %>
    <% end %>
  </div>

  <a class="add-quick-link-<%= slot_name.parameterize %>" href="#">Add a quick link</a>

<%
  end
end
%>

<script>
$('.add-quick-link-<%= slot_name.parameterize %>').unbind('click').click(function() {

  // Get the template HTML
  var template = $('#quicklink-template-<%= slot_name.parameterize %>').html();

  // Add it
  var container = $('#quicklinks-<%= slot_name.parameterize %>');
  container.append(template);

  return false;
});

$('.remove-quicklink').unbind('click').click(function() {
  $(this).parent().parent().remove();
  return false;
});
</script><commit_msg>Fix remove links not working with newly added form fields<commit_after><%= fields_for :node do |f| %>
  <%= f.fields_for slot_name, component do |f| %>
  <%= f.hidden_field :_type %>
  <%= error_messages_for :object => component %>

  <script id="quicklink-template-<%= slot_name.parameterize %>" type="text/x-jquery-tmpl">
    <%= render :partial  => 'admin/components/quick_link',
               :locals => {
                 :component => component,
                 :slot_name  => slot_name,
                 :text => "",
                 :link => "",
                 :index => nil
               }
    %>
  </script>

  <p>
    <%= label_tag "node_#{slot_name}_title", "Title" %><br />
    <span class="input-wrap"><%= text_field_tag "node[#{slot_name}][title]", component.title, :id => "node_#{slot_name}_title" %></span>
  </p>

  <div id="quicklinks-<%= slot_name.parameterize %>">

    <% component.quick_links.each_with_index do |quicklink, index| %>
      <%= render :partial  => 'admin/components/quick_link',
                 :locals => {
                   :component => component,
                   :slot_name  => slot_name,
                   :text => quicklink.link_text,
                   :link => quicklink.link,
                   :index => nil
                 }
      %>
    <% end %>

    <% if component.quick_links.empty? %>
      <%= render :partial  => 'admin/components/quick_link',
                 :locals => {
                   :component => component,
                   :slot_name  => slot_name,
                   :text => "",
                   :link => "",
                   :index => nil
                 }
      %>
    <% end %>
  </div>

  <a class="add-quick-link-<%= slot_name.parameterize %>" href="#">Add a quick link</a>

<%
  end
end
%>

<script>
$('.add-quick-link-<%= slot_name.parameterize %>').unbind('click').click(function() {

  // Get the template HTML
  var template = $('#quicklink-template-<%= slot_name.parameterize %>').html();

  // Add it
  var container = $('#quicklinks-<%= slot_name.parameterize %>');
  container.append(template);

  return false;
});

$('.remove-quicklink').unbind('click').live('click', function() {
  $(this).parent().parent().remove();
  return false;
});
</script>
{'fraction_non_alphanumeric': 0.1832660385823239, 'fraction_numerical': 0.0, 'mean_word_length': 2.0148749154834347, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4256709', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1328, 'n_words': 249}