# Displays datepicker to finished at date # when marking a planting finished using a # button. The button must have class 'append-date'. jQuery -> el = $('.append-date') el.datepicker({'format': 'yyyy-mm-dd'}) href = el.attr('href') originalText = el.text() el.click (e) -> e.stopPropagation() e.preventDefault() $(this).text('Confirm without date') $(this).bind('click.confirm', (e) -> link = $("") $('body').append(link) $(link).click() ) $(this).blur (e) -> $(this).text(originalText) $(this).unbind('click.confirm') el.one 'changeDate', -> date = $(this).datepicker('getDate') url = "#{href}&planting[finished_at]=#{date}" link = $("") $('body').append(link) $(link).click()