Yii Framework Forum: Passing Variables From Jquery To View - Yii Framework Forum

Jump to content

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

Passing Variables From Jquery To View Rate Topic: ***** 1 Votes

#1 User is offline   Pratik Shah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 21-November 12
  • Location:Ahmedabad

Posted 24 December 2012 - 01:31 AM

Hi I have created Fullcalendar on which if user clicks on any date am using Jquery to get the date. Below that I've form for events which takes Start date and end date and description. Now what i want is

when any one clicks on the Calendar that date should be get from by the Jquery which is already I am getting and the view model below the calendar's start date should be automatically filled with the clicked date.

So what i should do to achieve this.

I'm new to AJAX/JQuery/JSON and Yii.

Thanks for your time and consideration
0

#2 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 24 December 2012 - 01:53 AM

View PostPratik Shah, on 24 December 2012 - 01:31 AM, said:

Hi I have created Fullcalendar on which if user clicks on any date am using Jquery to get the date. Below that I've form for events which takes Start date and end date and description. Now what i want is

when any one clicks on the Calendar that date should be get from by the Jquery which is already I am getting and the view model below the calendar's start date should be automatically filled with the clicked date.

So what i should do to achieve this.

I'm new to AJAX/JQuery/JSON and Yii.

Thanks for your time and consideration



You mean to say you are looking for something like date-picker. Am i right ?? :mellow:
CodeSutra
0

#3 User is offline   Pratik Shah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 21-November 12
  • Location:Ahmedabad

Posted 24 December 2012 - 01:59 AM

Yeah I have date picker already in the form, Now if Anybody clicks on the calendar start date should be filled with the clicked date and End date will be picked by the date picker..Through Jquery i could alert the current date but I don't know how to send that variable to Start_date's model.
0

#4 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 24 December 2012 - 03:44 AM

View PostPratik Shah, on 24 December 2012 - 01:59 AM, said:

Yeah I have date picker already in the form, Now if Anybody clicks on the calendar start date should be filled with the clicked date and End date will be picked by the date picker..Through Jquery i could alert the current date but I don't know how to send that variable to Start_date's model.


Are you using Cjuidatepicker or something else.???

And if you are using Cjuidatepicker then i am sure it will do the same as you are expecting.
CodeSutra
0

#5 User is offline   Pratik Shah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 21-November 12
  • Location:Ahmedabad

Posted 24 December 2012 - 03:48 AM

Yes, I'm using the same.. but it is not happening.

I have written the following code to render the date picker.

<?php

echo $form->labelEx($model,'start_date');
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'start_date',
'value'=>$model->start_date,
'options'=>array(
'showAnim'=>'fold',
'showButtonPanel'=>true,
'autoSize'=>true,
'dateFormat'=>'dd-mm-yy',
'defaultDate'=>$model->start_date,
),
));
0

#6 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 24 December 2012 - 04:07 AM

View PostPratik Shah, on 24 December 2012 - 03:48 AM, said:

Yes, I'm using the same.. but it is not happening.

I have written the following code to render the date picker.

<?php

echo $form->labelEx($model,'start_date');
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'start_date',
//'value'=>$model->start_date,
'options'=>array(
'showAnim'=>'fold',
'showButtonPanel'=>true,
'autoSize'=>true,
'dateFormat'=>'dd-mm-yy',
//'defaultDate'=>$model->start_date,
),
));


Please check that code and also confirm that you are not getting any Js error.
And if you are setting value with $model->start_date then $model->start_date should be initialize.But i dont think that you need to use it.So, just go with the code what i have commented above.
CodeSutra
0

#7 User is offline   Pratik Shah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 21-November 12
  • Location:Ahmedabad

Posted 24 December 2012 - 04:14 AM

I don't think I am having any Js error And after commenting that line also its running the same way am not getting any error or warning.

To get the clicked date m writing this jquery

$(document).ready(function() {



$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
selectable:true,
selectHelper : true,

dayClick: function(date, allDay, jsEvent, view) {


// alert(date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear())

selectedDate=date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();


alert(selectedDate);

$("#mydialog").dialog("open"); return false;

//window.showModalDialog("<?php echo Yii::app()->createUrl("events/create");?>");

},
eventClick: function(){

alert("EVENT CLICKED");
},
0

#8 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 24 December 2012 - 04:42 AM

View PostPratik Shah, on 24 December 2012 - 04:14 AM, said:

I don't think I am having any Js error And after commenting that line also its running the same way am not getting any error or warning.

To get the clicked date m writing this jquery

$(document).ready(function() {



$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
selectable:true,
selectHelper : true,

dayClick: function(date, allDay, jsEvent, view) {


// alert(date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear())

selectedDate=date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear();


alert(selectedDate);

$("#mydialog").dialog("open"); return false;

//window.showModalDialog("<?php echo Yii::app()->createUrl("events/create");?>");

},
eventClick: function(){

alert("EVENT CLICKED");
},


Are you trying to open a form into a Dialog box.??
Why are you writing that custom jquery code.
Since it is a default behavior of Cjuidatepicker when you pick a date then it will automatically field in a text box.

This error is looked so wired to me.
CodeSutra
0

#9 User is offline   Pratik Shah 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 21-November 12
  • Location:Ahmedabad

Posted 24 December 2012 - 04:49 AM

Oh i got it...You understood my problem in other way, I am using Fullcalendar
http://www.yiiframew...n/fullcalendar/


and when i click on the date it should scroll down to my form which is below to that calendar and the start date of datepicker should automatically filled with the clicked date..

How to attach the snapshot I was searching from long..else would have showed you the snapshot..

hope my question is clear now..

so I have one calendar below that one form with 2 textboxes which are Datepicker.
0

#10 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 24 December 2012 - 05:43 AM

View PostPratik Shah, on 24 December 2012 - 04:49 AM, said:

Oh i got it...You understood my problem in other way, I am using Fullcalendar
http://www.yiiframew...n/fullcalendar/


and when i click on the date it should scroll down to my form which is below to that calendar and the start date of datepicker should automatically filled with the clicked date..

How to attach the snapshot I was searching from long..else would have showed you the snapshot..

hope my question is clear now..

so I have one calendar below that one form with 2 textboxes which are Datepicker.



How to attach the snapshot I was searching from long..else would have showed you the snapshot..


When you post a comment there is a file upload selector there.So you can upload attachments there.
And i will suggest you to go with Cjuidatepicker.it has a same possibilities as you are expecting.
CodeSutra
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