Categories

Friday, November 22, 2024
#919814419350 therichposts@gmail.com
FullCalendarPhp

how to stay on the last view after refreshing the page fullcalendar with php?

stay on the last view after refreshing the page fullcalendar with php - the rich post

Hello to all, welcome to therichpost.com. In this post, I will tell you, how to stay on the last view after refreshing the page fullcalendar with php?

I am sharing this code because I think, it will help others.

Here is the working and tested code for stay on the last view after refreshing the page fullcalendar with php and you need to add this code into your php file:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<style>

  body {
    margin: 40px 10px;
    padding: 0;
    font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
    font-size: 14px;
  }

  #calendar {
    max-width: 900px;
    margin: 0 auto;
  }

</style>
</head>
<body>

  <div id='calendar'></div>
  <form action="core_php.php" method="post" id="formpost">
  <input type="hidden" name="viewname" id="viewname">
  </form>
  <?php if(isset($_POST['viewname']))
  {
    $defaultView = $_POST['viewname'];
  }
  else
  {
    $defaultView = 'basicWeek';
  }
  
  
  ?>
  <link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.css' rel='stylesheet' />
<link href='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.print.min.css' rel='stylesheet' media='print' />
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/lib/moment.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src='https://fullcalendar.io/releases/fullcalendar/3.9.0/fullcalendar.min.js'></script>
<script>
$(document).ready(function() {
$(document.body).on("keydown", this, function (event) {
    if (event.keyCode == 116) {
    $("#formpost").submit();
    }
    });
$(document).on('click', '.fc-button', function(event) {
    var viewname = $(this).attr('class');
    viewname = viewname.split(" ");
    viewname = viewname[0].split("-");
    $("#viewname").val(viewname[1]);
    /* Act on the event */
    });
$('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,basicDay'
      },
      defaultDate: '2018-03-12',
    defaultView: "<?php echo $defaultView;?>",
      navLinks: true, // can click day/week names to navigate views
      editable: true,
      eventLimit: true, // allow "more" link when too many events
      events: [
        {
          title: 'All Day Event',
          start: '2018-03-01'
        },
        {
          title: 'Long Event',
          start: '2018-03-07',
          end: '2018-03-10'
        },
        {
          id: 999,
          title: 'Repeating Event',
          start: '2018-03-09T16:00:00'
        },
        {
          id: 999,
          title: 'Repeating Event',
          start: '2018-03-16T16:00:00'
        },
        {
          title: 'Conference',
          start: '2018-03-11',
          end: '2018-03-13'
        },
        {
          title: 'Meeting',
          start: '2018-03-12T10:30:00',
          end: '2018-03-12T12:30:00'
        },
        {
          title: 'Lunch',
          start: '2018-03-12T12:00:00'
        },
        {
          title: 'Meeting',
          start: '2018-03-12T14:30:00'
        },
        {
          title: 'Happy Hour',
          start: '2018-03-12T17:30:00'
        },
        {
          title: 'Dinner',
          start: '2018-03-12T20:00:00'
        },
        {
          title: 'Birthday Party',
          start: '2018-03-13T07:00:00'
        },
        {
          title: 'Click for Google',
          url: 'http://google.com/',
          start: '2018-03-28'
        }
      ]
    });

  });

</script>

</body>
</html>

 If you have any query related to this post then please let me know or you can ask the questions also.

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.