var el = "<%= "#" + dom_id(peritonitis_episode) %>"; <% if peritonitis_episode.valid? %> $(el).replaceWith("<%= escape_javascript( render "details", local_assigns ) %>"); <% else %> $(el).replaceWith("<%= escape_javascript( render "form", local_assigns ) %>"); initDatepickersIn(el); $("#peritonitis_episode_types .searchable_select").select2(); <% end %>