Arafat Rahman February 2016

about php full calendar

When I click on an item in the calendar it will show its particular task. After one second the calendar will disappear. But I want to show the task without disappearing. When I add a function to call the calendar according to the item, then this problem has started.

This is the code into the jquery

{
    guyid = "";

    $('.guyid').click(function (){
        this.guyid = $(this).attr('id');
    //  alert('test:'+this.guyid);
            CalenderCall(this.guyid);

    });

    function CalenderCall(guyid){

//alert(guyid);
        $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicDay'
                },
                editable: true,
                eventLimit: true, // allow "more" link when too many events

                events: [
                    {
                        title: guyid,
                        start: '2016-02-04'
                    },
                    {
                        title: 'Event1',
                        start: '2016-02-04'
                    },

                    {
                        title: 'Event1',
                        start: '2016-02-17'
                    },
                    {
                        title: 'Long Event',
                        start: '2016-02-06',
                        end: '2016-02-10'
                    }

                    // etc...
                    ],
                    color: 'yellow',   // an option!
                    textColor: 'black' // an option!
        });
    }

});

this is the body part

<!-- <div style="width: auto; height: 200px; border: 2px solid black;"></div> -->
<a href="tasks.php"><b>Tasks</b></a><br>
<div style="position: absolute;">
<?php
    $phplink = mysql_connect('localhost:3306', 'root', '');
    if (!$phpli        

Answers


Chintan Mirani February 2016

Ok, then you have to do something like below

First of all change your code with below one.

<!-- <div style="width: auto; height: 200px; border: 2px solid black;"></div> -->
<a href="tasks.php"><b>Tasks</b></a><br>
<div style="position: absolute;">
<?php
    $phplink = mysql_connect('localhost:3306', 'root', '');
    if (!$phplink) {
        die("Could not connect:" .mysql_error());
    }
    $db = mysql_select_db('jhoro_pm', $phplink) or die("Could not connect to db:" .mysql_error());
    $result_guy = mysql_query("SELECT id, name, can_login FROM person WHERE can_login=1");
    while ($row_guy=mysql_fetch_array($result_guy)) {
        echo '<a href="javascript:void(0);" class="guyid" id="' .$row_guy[0]. '">' .$row_guy[1]. '</a><br>';

    }

        echo '<input type="hidden" id="selectedPerson" class="guyid" value="' .$row_guy[0]. '" />';
?>

1) Remove href="index.php" from your anchor tag. (href will call every click, that's why your calendar disappears. 2) Set hidden field for selected person. (Out side while loop).

Now, some fine tunning of your jQuery code.

{
    guyid = "";

    $('.guyid').click(function (){
        this.guyid = $(this).attr('id');
        $('#selectedPerson').val(this.guyid);
        $('#calendar').fullCalendar('rerenderEvents');
    });

        $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,basicDay'
                },
                editable: true,
                eventLimit: true, // allow "more" link when too many events

                events: [
                    {

                        title: 1,
                        start: '2016-02-04'
                    },
                    {
                        title: 2,
                        start: '2016- 


Chintan Mirani February 2016

Keep your existing code (that you mention in your question) as it is.

Just add simple ajax url as below to load person wise task.

events: "urltofetchpersonwisetasks/?guyid="+guyid,

And server get this request with guyid as request parameter and make database call to get person's task and send json response. Like json_encode(person_task_array). This will automatically load selected person;s task.

Post Status

Asked in February 2016
Viewed 1,299 times
Voted 6
Answered 2 times

Search




Leave an answer