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

201
Views
¿Cómo hago para que $.serialize() tenga en cuenta los elementos de entrada deshabilitados?

Parece que, por defecto, los elementos de entrada deshabilitados son ignorados por $.serialize() . ¿Hay una solución?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Habilítelos temporalmente.

 var myform = $('#myform'); // Find disabled inputs, and remove the "disabled" attribute var disabled = myform.find(':input:disabled').removeAttr('disabled'); // serialize the form var serialized = myform.serialize(); // re-disabled the set of inputs that you previously enabled disabled.attr('disabled','disabled');
over 4 years ago · Santiago Trujillo Report

0

Use entradas de solo lectura en lugar de entradas deshabilitadas:

 <input name='hello_world' type='text' value='hello world' readonly />

Esto debería ser recogido por serialize().

over 4 years ago · Santiago Trujillo Report

0

Puede usar una función de proxy (afecta tanto a $.serializeArray() como $.serialize() ):

 (function($){ var proxy = $.fn.serializeArray; $.fn.serializeArray = function(){ var inputs = this.find(':disabled'); inputs.prop('disabled', false); var serialized = proxy.apply( this, arguments ); inputs.prop('disabled', true); return serialized; }; })(jQuery);
over 4 years ago · Santiago Trujillo 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!