Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/11/2013, 10:39
Avatar de Maverick2786
Maverick2786
 
Fecha de Ingreso: diciembre-2012
Mensajes: 107
Antigüedad: 11 años, 5 meses
Puntos: 1
Problema con datepicker

Tengo esto:
Código Javascript:
Ver original
  1. function ingresarFechasCalendario(fechaBaseDatos)
  2.             {
  3.                 var dates = ['11-10-2013', '11-12-2013'];
  4.                 //tips are optional but good to have
  5.  
  6.                 $('#fechaBitacora1').datepicker({
  7.                     dateFormat: 'dd/mm/yy',
  8.                     beforeShowDay: highlightDays,
  9.                     showOtherMonths: true,
  10.                     numberOfMonths: 1,
  11.                 });
  12.  
  13.                 function highlightDays(date) {
  14.                     for (var i = 0; i < dates.length; i++) {
  15.                         if (new Date(dates[i]).toString() == date.toString()) {
  16.                             return [true, 'highlight', ];
  17.                         }
  18.                     }
  19.                     return [true, ''];
  20.                 }
  21.  
  22.             }

pero al tenerlo dentro de una funcion me da este error:
Uncaught TypeError: Object [object Object] has no method 'datepicker'

en cambio si lo tengo de esta forma , si funciona:
Código Javascript:
Ver original
  1. $(document).ready(function() {
  2.                 var dates = ['11-10-2013', '11-12-2013'];
  3.                 //tips are optional but good to have
  4.  
  5.                 $('#fechaBitacora1').datepicker({
  6.                     dateFormat: 'dd/mm/yy',
  7.                     beforeShowDay: highlightDays,
  8.                     showOtherMonths: true,
  9.                     numberOfMonths: 1,
  10.                 });
  11.  
  12.                 function highlightDays(date) {
  13.                     for (var i = 0; i < dates.length; i++) {
  14.                         if (new Date(dates[i]).toString() == date.toString()) {
  15.                             return [true, 'highlight', ];
  16.                         }
  17.                     }
  18.                     return [true, ''];
  19.                 }
  20.  
  21.             });

pero yo necesito llamarlo en un evento especifico por medio de boton , no cuando cargue

muchas gracias