Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda