Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
Run a Ruby service inside Javascript inside HTML

I have a view with a simple_form and an input called priority. Before the submit button I have Your request is going to cost $X. My X cost is going to change accordingly to what the user select in the priority input.

The thing is I need to get the priority input from the user to call a Ruby service, get the result and add it to the Your request is going to cost $X.

What I have in my view is something like:

= f.input :priority

p Your request is going to cost <strong id="selected-priority">0</strong>.
= f.submit "Send",
javascript:
   $('#priority').on("change", function(e) {
    var priorityInput = $(this).val(); # this is going to return something like "EMERGENCY"
    var totalInDollars = #{CalculateAmount.call(priority: ??)};
    $('#selected-priority').text("$" + totalInDollars);
  }).change();

This is all working but I have no idea how to add the priorityInput js variable to my service call.

Could someone help? Tks!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda