This repository was archived by the owner on Apr 25, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-15
lines changed
assets/javascripts/components Expand file tree Collapse file tree 2 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,15 @@ jQuery(function($) {
4242 initializeAutocomplete ( 'competition_tracks_attributes_' + i + '_end_city_attributes_name' ) ;
4343 }
4444
45+ // TODO: this is nasty... can we make it cleaner?
4546 nestedForm = $ ( '.tracks_form' ) . last ( ) . clone ( ) ;
46-
47- // remove empty-field if edit
48- if ( $ ( '.tracks_form' ) . length > 1 ) {
49- $ ( '.tracks_form' ) . last ( ) . remove ( ) ;
50- }
47+ nestedForm . find ( "input" ) . val ( "" ) ;
48+ nestedForm . find ( ".has-error" ) . removeClass ( "has-error" ) ;
49+ nestedForm . find ( ".help-block" ) . remove ( ) ;
50+ destroy_link = nestedForm . find ( ".destroy_track" ) ;
51+ destroy_link . attr ( 'data-confirm' , '' ) ;
52+ destroy_link . attr ( 'data-method' , '' ) ;
53+ destroy_link . attr ( "href" , "#" ) ;
5154
5255 $ ( ".destroy_track:first" ) . remove ( ) ;
5356 $ ( 'body' ) . on ( 'click' , '.destroy_track' , function ( e ) {
Original file line number Diff line number Diff line change @@ -62,12 +62,10 @@ def published?
6262 end
6363
6464 def prepopulate_tracks! ( _options )
65- 2 . times do
66- track = Track . new
67- track . build_start_city
68- track . build_end_city
69- tracks << track
70- end
65+ track = Track . new
66+ track . build_start_city
67+ track . build_end_city
68+ tracks << track
7169 end
7270
7371 def populate_city! ( options )
@@ -98,10 +96,7 @@ class Update < Create
9896 private
9997
10098 def prepopulate_tracks! ( _options )
101- track = Track . new
102- track . build_start_city
103- track . build_end_city
104- tracks << track
99+ tracks = tracks
105100 end
106101 end
107102 end
You can’t perform that action at this time.
0 commit comments