Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/03/2011, 07:15
Avatar de Dundee
Dundee
 
Fecha de Ingreso: junio-2002
Ubicación: El Médano
Mensajes: 1.310
Antigüedad: 21 años, 10 meses
Puntos: 8
Jquery Datepicker desactivar periodos de fechas

Hola gente, sigo peleándome y aprendiendo cada dia maś sobre esta magnífica API Datepicker de la UI de Jquery.
El tema es que estoy viendo esto (despúes de buscar un rato por Google):
http://jsbin.com/ezomu/edit
Y necesito desactivar un periodo de fechas , por ejemplo del 15 de marzo al 25 de julio, pero no lo consigo.
Resulta que el contenido del array dateList yo pensaba que era la fecha en formato timestamp (acostumbrado a PHP :) ) , pero he comprobado esas fechas de ejemplo y no son fechas válidas (el timestamp es demasiado pequeño, para comprobarlo online se puede entrar aquí).
¿Que es lo que contiene ese array?.
Si alguien me puede arrojar algo de luz le estaría muy agradecido.
El código de ejemplo está en esa url , pero por si acaso lo pego aquí.

Código:
var dateList = new Array();
dateList.push("20091012"); //¿ESTO QUE ES ? (NO es un timestamp válido)
dateList.push("20091019");
dateList.push("20091026");
dateList.push("20091110");

$("#dp").datepicker({
  minDate: $.datepicker.parseDate('yymmdd', dateList[0]), //this makes the datepicker start at the first available
  beforeShowDay: function(dateToShow){
    return [($.inArray($.datepicker.formatDate('yymmdd', dateToShow),dateList) >= 0), ""];
  }

});
$("#dp2").datepicker({
  minDate: $.datepicker.parseDate('yymmdd', dateList[0]),
  maxDate: $.datepicker.parseDate('yymmdd', dateList[dateList.length-1])
});
y el HTML por si a alguien le interesa
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/sunny/jquery-ui.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<title>Sandbox</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

</head>
<body class="ui-widget-content">
  <p>This will only show the dates in a given array using the beforeShowDay option.</p>
  <p>
    <input type="text" id="dp"></input>
  </p>
  <p>However, if the dates are contiguous, you may want to use the minDate and maxDate instead.<br/>
  This will prevent the datepicker from moving to months/year outside the range...
  </p>
  <p>
    <input type="text" id="dp2"></input>
  </p>
</body>
</html>
Mil gracias
__________________
Videotutoriales de Drupal