Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Mensaje flash de Rails después del éxito de AJAX

Tengo que preguntar sobre algo que probablemente ya nadie use. Quiero mostrar flash[:notice] después de una acción AJAX exitosa. Soy consciente de esto y aquello e incluso de esta esencia , pero ninguno de ellos se ajusta a mi ejemplo:

 #controller code def new @registrant = Registrant.new respond_to do |format| format.html if params[:add_patient_to_caregiver] format.js { render partial: 'add_patient_to_caregiver' } end end end #view triggered controller#new action via AJAX <%= link_to 'Add Patient to Caregiver', patient_to_caregiver_path(add_patient_to_caregiver: true, patient_to_caregiver: registrant.id), method: :get, remote: true %>

Quiero tener algo como format.js { render partial: 'add_patient_to_caregiver', flash[:notice] = 'Patient Added' } para mostrarlo en una vista. He encontrado una solución alternativa:

_add_patient_to_caregiver.js.erb

 $("#add-patient").html("<%= escape_javascript(render :partial => 'registrants/add_patient') %>"); $("#flash-messages").after("<div class='alert alert-success'> Patient Added </div>");

Y aparece un mensaje flash, pero no hay ningún botón de cierre allí. ¿Hay alguna manera mejor de hacerlo? o ¿cómo agregar el botón de cerrar a ese mensaje para que no se vuelva a cargar toda la página cuando se presiona?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!