$(() => {
  $('#modal-window').html('<%= escape_javascript(render "shared/dynamic_form/modal") %>');
  $('#modal-window').modal();


  $('#modal_fragment_form').bind('ajax:success', (event, response) => {
    switch (response.classname) {
    case 'research_output':
      $('#research-outputs-list').html(response.html);
      break;
    default:
      $(`.fragment-${response.fragment_id} .linked-fragments-list.${response.classname}-list tbody`).html(response.html);
    }
    $('#modal-window').modal('hide');
  }).bind('ajax:error', () => {
    console.log('ajax:error');
  });
});
