Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/05/2012, 06:38
Avatar de Lucieta86
Lucieta86
 
Fecha de Ingreso: noviembre-2010
Mensajes: 45
Antigüedad: 13 años, 5 meses
Puntos: 1
dialogo en jquery, problemas al abrirlo reiteradas veces

Hola chicos,

Tengo un formulario en un script que se abre con ajax, este le pasa todos los valores por post, y muestra un dialogo.

El problema lo tengo cuando abro el formulario en reiteradas veces, ya que este me sigue manteniendo los valores anteriores siempre, es decir que no actualiza su valor.

He probado a quitar el código del dialogo, de modo que se abriera como una página nueva y si recoge bien los valores, y los actualiza con cada llamada, de modo que el problema reside en el código javascript del dialogo.

Os dejo el código:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
  4.  
  5. <?php
  6. require "config.php";
  7. require "connect_db.php";
  8. require "functions.php";
  9. ?>
  10.  
  11. <script type="text/javascript">
  12.  
  13. $(function(){
  14.     $( "#dialog-form" ).dialog( "destroy" );
  15.        
  16.     $( "#dialog-form" ).dialog({
  17.         autoOpen: false,
  18.         height: 600,
  19.         width: 350,
  20.         modal: true,
  21.         buttons: {
  22.             "Realizar Reserva": function() {
  23.                 $(this).dialog( "close" );
  24.                
  25.             },
  26.             "Cancelar": function() {
  27.                 $( this ).dialog( "close" );
  28.                
  29.             }
  30.         },
  31.         close: function() {
  32.             allFields.val( "" ).removeClass( "ui-state-error" );
  33.         }
  34.     });
  35.    
  36.         $( "#dialog-form" ).dialog( "open" );
  37.        
  38. });
  39.    
  40. <style type="text/css">
  41. input.text, textarea, select  { margin-bottom:12px; width:90%; padding: .5em; }
  42. fieldset { padding:10; border: 1px solid #9CF; border-radius:15px; margin-top:25px; width:83%; }
  43. h1 { font-size: 1.2em; margin: .6em 0; }
  44. .ui-dialog .ui-state-error { padding: .3em; }
  45. .validateTips { border: 1px solid transparent; padding: 0.3em; }
  46. </style>    
  47.    
  48. </head>
  49.  
  50. <?php
  51. //Recoge los valores que necesita
  52.  
  53. $feInicio=$_REQUEST["fIni"];
  54. $feFin=$_REQUEST["fFin"];
  55. $opcAulasRes=$_REQUEST["seleAulas"];
  56.  
  57. //Obtener los datos de los responsables
  58. $datos_responsable=get_responsable();
  59. $resp_list="";
  60.     for ($i=0;$i<sizeof($datos_responsable);$i++)
  61.     {
  62.         $resp_list.= "<option value=\"".$datos_responsable[$i][1]. "\"";
  63.         $resp_list.=">".$datos_responsable[$i][0]."</option>". chr(10);
  64.     }
  65.  
  66.  
  67. //Pasar a array las aulas seleccionadas
  68. $aulasRes=explode(',', $opcAulasRes);
  69.  
  70. ?>
  71. <div id="dialog-form" title="FORMULARIO RESERVA">
  72.  
  73.         <legend>Datos selección</legend>
  74.         <label for="fyhini">Fecha inicio: <?php echo $feInicio;?></label> <br/><br/>
  75.         <label for="fyhfin">Fecha fin: <?php echo $feFin;?></label> <br/><br/>
  76.         <label for="espacioSelec">Espacio Seleccionado:
  77.        
  78.         <?php
  79.         //echo "VALORES".$opcAulasRes."-".$fechaInicio."-".$fechaFin;
  80.         //die();
  81.         for($aux=0; $aux<count($aulasRes); $aux++){
  82.             if($aux==0) echo $aulasRes[$aux];
  83.             else echo " - ".$aulasRes[$aux];
  84.             }
  85.         ?>
  86.        
  87.         </label>
  88.     </fieldset>
  89.         <br/><br/>
  90.         <label for="name">Responsable*</label> <br/>
  91.         <select id="name" class="text ui-widget-content ui-corner-all" name="name">
  92.         <option  value:"-1" >---Seleccione responsable---</option><?php echo $resp_list; ?></select>
  93.         <br/>
  94.         <label for="email">Email*</label><br/>
  95.         <input type="text" name="mailResp" id="mailResp" value="" class="text ui-widget-content ui-corner-all" />
  96.         <br/>
  97.         <input type="checkbox" id="enviarMail" name="enviarMail" value="mail"/> Enviar email
  98.         <br/><br/>
  99.         <label for="desc">Descripcion*</label>
  100.         <input type="text" name="desc" id="desc" value="" class="text ui-widget-content ui-corner-all" />
  101.          <br/>
  102.         <label for="obser">Observaciones</label>
  103.         <textarea name="obser" id="obser" value="" class="text ui-widget-content ui-corner-all" />
  104.         <br/>
  105.         <label for="comentario">* Campos obligatorios</label>
  106.    
  107. </div>
  108. </form>  
  109.  
  110. </body>
  111. </html>


Alguna idea?

Gracias