Convert coffeescript to javascript in admin area

#341
This commit is contained in:
Artur Beljajev 2017-01-18 08:35:38 +02:00
parent 40459e8b2e
commit 2c9a8b555b
3 changed files with 34 additions and 22 deletions

View file

@ -31,16 +31,22 @@
- value = f.object.new_record? ? '' : f.object.status_notes[s]
= text_field_tag "#{model}[status_notes_array][]", value, class: 'form-control'
:coffee
$("#js-statuses").nestedAttributes
bindAddTo: $(".js-add-status")
afterAdd: (el) ->
if el.find('.js-disabled-value')
el.find('.js-disabled-value').remove()
el.find('.js-select').show()
el.find('.hide-when-new').hide()
el.find('.js-destroy-status').show()
:javascript
window.addEventListener('load', function() {
$("#js-statuses").nestedAttributes({
bindAddTo: $(".js-add-status"),
afterAdd: function(el) {
if (el.find('.js-disabled-value')) {
el.find('.js-disabled-value').remove();
el.find('.js-select').show();
el.find('.hide-when-new').hide();
return el.find('.js-destroy-status').show();
}
}
});
$(document).on 'click', '.js-destroy-status', (e) ->
e.preventDefault()
$(this).parents('.panel').remove()
$(document).on('click', '.js-destroy-status', function(e) {
e.preventDefault();
return $(this).parents('.panel').remove();
});
});