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

188
Views
deshabilite el botón Enviar hasta que todas las entradas del formulario tengan un valor en Rails

Me gustaría deshabilitar el botón de envío de formulario hasta que todas las entradas tengan un valor en ellas. Mi vista tiene estas entradas:

 <%= form_for @item, html: { enctype: "multipart/form-data", id: "upload-data" } do |f| %> <%= f.text_field :name %> <% end %>

Luego ejecuto esta función de validate() con cada evento de keyup :

 $(document).ready(function() { validate(); $('input').on('keyup', validate); }); function validate() { var input = $('input'); var isValid = false; $.each(input, function(k, v) { if (v.type != "submit") { isValid = (k == 0) ? v.value ? true : false : isValid && v.value ? true : false; } if (isValid) { $("input[type=submit]").prop("disabled", false); } else { $("input[type=submit]").prop("disabled", true); } }); }

Aunque el mismo código funciona aquí , no funciona en mi vista de Rails. Se mantiene deshabilitado. ¿Qué estoy pasando por alto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

tal vez porque turbolinks, en Rails no puede simplemente copiar y pegar el javascript que necesita para adaptarlo al script y sintaxis de turbolinks

podría intentar cambiar su script de

 $(document).ready(function() { });

dentro

 $(document).on('ready turbolinks:load', function() { })
about 4 years ago · Juan Pablo Isaza Report
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!