Permalink
Browse files

add/remove track: remove hack

  • Loading branch information...
NoryDev committed Aug 13, 2016
1 parent 19b1b34 commit 5c151dc5167152905c0c78555dab9b96977497aa
Showing with 13 additions and 15 deletions.
  1. +8 −5 app/assets/javascripts/components/mvp.js
  2. +5 −10 app/concepts/competition/contract.rb
@@ -42,12 +42,15 @@ jQuery(function($) {
initializeAutocomplete('competition_tracks_attributes_'+ i +'_end_city_attributes_name');
}
// TODO: this is nasty... can we make it cleaner?
nestedForm = $('.tracks_form').last().clone();
// remove empty-field if edit
if ($('.tracks_form').length > 1) {
$('.tracks_form').last().remove();
}
nestedForm.find("input").val("");
nestedForm.find(".has-error").removeClass("has-error");
nestedForm.find(".help-block").remove();
destroy_link = nestedForm.find(".destroy_track");
destroy_link.attr('data-confirm', '');
destroy_link.attr('data-method', '');
destroy_link.attr("href", "#");
$(".destroy_track:first").remove();
$('body').on('click', '.destroy_track', function(e) {
@@ -62,12 +62,10 @@ def published?
end
def prepopulate_tracks!(_options)
2.times do
track = Track.new
track.build_start_city
track.build_end_city
tracks << track
end
track = Track.new
track.build_start_city
track.build_end_city
tracks << track
end
def populate_city!(options)
@@ -98,10 +96,7 @@ class Update < Create
private
def prepopulate_tracks!(_options)
track = Track.new
track.build_start_city
track.build_end_city
tracks << track
tracks = tracks
end
end
end

0 comments on commit 5c151dc

Please sign in to comment.