Yii Framework Forum: Ajax Parameters Aren't Sent With Ajaxlink - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Parameters Aren't Sent With Ajaxlink Rate Topic: -----

#1 User is offline   Yoggsoft 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-October 12
  • Location:Buenos Aires

Posted 08 March 2013 - 12:05 PM

Hey guys, im having quite of a bad time here. I'm using flowing calendar and i'm extending part of it's functionallity to suit my needs...
basic logic:
calendar, next and previous buttons refresh months through ajax and not reloading the site.

/extensions/flowing-calendar/views/flowingCalendar
$this->storePreviousLink = CHtml::ajaxLink(
                                    "<<",
                                    Yii::app()->createUrl('evento/updateCalendar', <-CONTROLLER
									array(
										'type'=>'POST',
                                        'data'=>array('month'=>$this->previousMonth,'year'=>$this->yearPreviousMonth),
                                        )), // Yii URL
                                    array('update' => '#CalendarArea') // jQuery selector
									
 
);

AND MY CONTROLLER:
public function actionUpdateCalendar(){
			
            if (isset($_POST['month'])){
				$mes = $_POST['month'];
				$anyo = $_POST['year'];
                $this->widget('ext.flowing-calendar.FlowingCalendarWidget', array("month"=>$mes, "year"=>$anyo));
            }else{
                $this->widget('ext.flowing-calendar.FlowingCalendarWidget', array("month"=>2, "year"=>2014));
            }
			Yii::app()->end();
        }

so basically when i click the next or prev button of the calendar, should switch between months, but my controller ain't receiving any POST parameters. the refresh works good because it's rendering february 2014. but there's no way it can receive POST[month] or POST[year]...

what can i be doing wrong or what other coice do i have?
i'm quite a noob at Yii and Ajax

Thx in advantage
0

#2 User is offline   Yoggsoft 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-October 12
  • Location:Buenos Aires

Posted 12 March 2013 - 04:14 PM

Finally got it working! turned out to be just a syntax thing... if anyone is having something like this...

Controller
 public function actionUpdateListaEventosDia(){
           if (isset($_POST['dia']) && isset($_POST['mes']) && isset($_POST['anio'])){
                $dia = $_POST['dia'];
                $mes = $_POST['mes'];
                $anio = $_POST['anio'];
                $usuario = Usuario::model()->getUsuarioSession();
                $datos = $usuario->getEventosDelDia($dia,$mes,$anio);
                $this->renderPartial('_listaDia',array('eventos'=>$datos));
            }else{
                $this->renderPartial('_crearEvento');
            }
        }


AJAX LINK
$dia = CHtml::ajaxButton(
                                        $list_day,
                                        Yii::app()->createUrl('evento/updateListaEventosDia'),
                                                array(
                                                    'type' => 'POST',
                                                    'data' => array(
                                                        'dia' => $list_day,
                                                        'mes' => $this->month,
                                                        'anio' => $this->year,
                                                        ),
                                                    'update' => '#loadWidget',
                                                    ),
                                                array(
                                                    'href' => Yii::app()->createUrl('evento/updateListaEventosDia'),
                                                )
                                        );

ajax link syntax:
CHTML::ajaxlink (
1.- name
2.- url to create or action to ejecute
3.- ajax options (type, update, data, success, beforeSubmit... and so on)
4.- html options (id, href, method, ....)
)

problem was that i've been declaring "update" attr inside HTML options...
0

#3 User is offline   Victor K. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 30-June 13

Posted 30 June 2013 - 02:27 PM

can you pls show your _listaDia and _crearEvento files inside, really need it, thx.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users