Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/03/2012, 05:54
educacanis
 
Fecha de Ingreso: octubre-2010
Ubicación: Madrid
Mensajes: 295
Antigüedad: 13 años, 6 meses
Puntos: 12
pasar una función de prototype a jquery

hola, como ya sabemos todos, existen problemas de interacción entre prototype y jquery, así que poco a poco voy cambiando las funciones para tenerlas todas en jquery y que así no haya problemas.

sin embargo, aún mis conocimientos no son muy allá y no consigo hacerlo del todo.

La función en Prototype es la siguiente:

Código Javascript:
Ver original
  1. <script src="js/Prototype.js" type="text/javascript"></script>
  2. <script type="text/javascript" language="javascript">
  3.     var current_month = <?PHP echo @$month ?>;
  4.     var current_year = <?PHP echo @$year ?>;
  5.    
  6.     function getPrevMonth()
  7.     {
  8.         if(current_month == 1)
  9.         {
  10.             current_month = 12;
  11.             current_year = current_year - 1;
  12.         }
  13.         else
  14.         {
  15.             current_month = current_month - 1;
  16.         }
  17.         params = 'month='+current_month+'&year='+current_year;
  18.         new Ajax.Updater('calendar_wrapper',window.location.pathname,{method:'post',parameters: params});
  19.        
  20.    
  21.        
  22.     }

Por ahora he pasado la función Ajax.Updater() por $.load()

pero no funciona, me carga toda la página de nuevo, no sólo el div. Así que creo que los parámetros se cogen de diferente manera, si alguien puede ayudar.

Código Javascript:
Ver original
  1. <script type="text/javascript" src="js/jquery.js"></script>
  2.  
  3. <script type="text/javascript" language="javascript">
  4.     var current_month = <?PHP echo @$month ?>;
  5.     var current_year = <?PHP echo @$year ?>;
  6.    
  7.     function getPrevMonth()
  8.     {
  9.         if(current_month == 1)
  10.         {
  11.             current_month = 12;
  12.             current_year = current_year - 1;
  13.         }
  14.         else
  15.         {
  16.             current_month = current_month - 1;
  17.         }
  18.         params = 'month='+current_month+'&year='+current_year;
  19.         $('#calendar_wrapper').load(window.location.pathname,{method:'post',parameters: params});
  20.    
  21.        
  22.     }

O si no algún manual a ser posible en español donde pueda ver las cosas. Gracias