$('#dialog h3.modal-title').html("Agregar Cliente"); // Render the edit form $('.modal-body-content').html('<%= j render "customers/form_remote" %>') // Show the dynamic dialog $('#dialog').modal("show"); // Set focus to the first element $('#dialog').on('shown.bs.modal', function () { $('.first_input').focus(); })