Ver Mensaje Individual
  #4 (permalink)  
Antiguo 02/10/2011, 23:39
Avatar de cristian_cena
cristian_cena
Colaborador
 
Fecha de Ingreso: junio-2009
Mensajes: 2.244
Antigüedad: 14 años, 10 meses
Puntos: 269
Respuesta: tinyMCE y jquery, deja de funcionar para multiples textareas dinamicos

Otro problema que se me presento es que si enviamos los multiples textareas con $.post() con jquery, es decir, con ajax. Los name no se serializan. Luego de muchas pruebas y errores la solución no pudo ser más simple.
Descargar la version jquery del tinymce y todo empieza a andar magicamente. Los textareas multiples los creas en dos patadas y se serializan los name.

Les dejo un ejemplo funcionando.

multiples_textareas.html
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  3.     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  4.     <title></title>
  5.     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  6.     <script type="text/javascript" src="tinymce_jq/jscripts/tiny_mce/jquery.tinymce.js"></script>
  7.     <script type="text/javascript" >
  8.     $().ready(function() {
  9.         $("textarea").tinymce({
  10.             script_url : 'tinymce_jq/jscripts/tiny_mce/tiny_mce.js',
  11.             theme : "simple"
  12.         });
  13.         $("#agregar").live('click', function(){
  14.             var textarea = $("<textarea name='descripcion[]'></textarea>");
  15.             textarea.appendTo("#formu");
  16.             textarea.tinymce({
  17.                     script_url : 'tinymce_jq/jscripts/tiny_mce/tiny_mce.js',
  18.                     theme : "simple"
  19.             });
  20.         });
  21.         $("#formulario").submit(function(event){
  22.             event.preventDefault();
  23.             $.post(
  24.                 "post.php", $("#formulario").serialize(), function(){ /*callback*/ }
  25.             );     
  26.         });
  27.     });
  28.     </script>
  29. </head>
  30.     <form action="post.php" id="formulario" method="post">
  31.         <div id="formu">
  32.             <textarea name="descripcion[]"></textarea>         
  33.             <textarea name="descripcion[]"></textarea>         
  34.         </div>
  35.         <input type="submit" value="enviar" />
  36.         <input type="button" value="agregar" id="agregar" />
  37.     </form>
  38. </body>
  39. </html>