anchor.diff:    }
   }
   $(function() { scheduling_polls_update_date_picker(true); });
  +function scheduling_polls_add_item(template) {
  +  "use strict";
  +
  +  var child_index = $("#scheduling_poll_add_item_link").parents("form").find("input[type=text][id^=scheduling_poll_scheduling_poll_item_attributes_]").length;
  +  $("#scheduling_poll_add_item_link").parent().before(template.replace(/CHILD_INDEX/g, child_index));
  +  scheduling_polls_update_date_picker();
  +}
   EOD
   %>
  
positive.code:   <%= f.submit %>
  </div>
  
  <%= javascript_tag <<"EOD"
  function scheduling_polls_update_date_picker(enable) {
    "use strict";
    if (enable === undefined) {
  
negative.code:   <%= f.fields_for :scheduling_poll_item do |f_item| %>
      <%= render :partial => "scheduling_poll_item_form", :locals => { :f => f, :f_item => f_item } %>
    <% end %>
    <% add_item_tmpl = capture do %>
      <%= f.fields_for :scheduling_poll_item, SchedulingPollItem.new, :child_index => "CHILD_INDEX" do |f_item| %>
        <%= render :partial => "scheduling_poll_item_form", :locals => { :f => f, :f_item => f_item } %>
      <% end %>
    <% end %>
    <p>
      <%= link_to_function 'Add item', "scheduling_polls_add_item(\"#{escape_javascript(add_item_tmpl)}\")", :class => 'icon icon-add', :id => 'scheduling_poll_add_item_link' %>
    </p>
  </div>
  
  