Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 742375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:44:27+00:00 2026-05-14T08:44:27+00:00

I’m very new to jquery and programming in general but I’m still trying to

  • 0

I’m very new to jquery and programming in general but I’m still trying to achieve something here.

I use Fullcalendar to allow the users of my web application to insert an event in the database. The click on a day, view changes to agendaDay, then on a time of the day, and a dialog popup opens with a form. I am trying to combine validate (pre-jquery.1.4), jquery.form to post the form without page refresh

The script calendar.php, included in several pages, defines the fullcalendar object and displays it in a div:

$(document).ready(function() {

    function EventLoad() {
        $("#addEvent").validate({
            rules: {
                calendar_title: "required",
                calendar_url: {
                    required: false,
                    maxlength: 100,
                    url: true
                }
            },
            messages: {
                calendar_title: "Title required",
                calendar_url: "Invalid URL format"
            },
            success: function() {
                $('#addEvent').submit(function() { 
                    var options = { 
                        success:    function() {
                            $('#eventDialog').dialog('close');
                            $('#calendar').fullCalendar( 'refetchEvents' );
                        } 
                    }; 

                    // submit the form 
                    $(this).ajaxSubmit(options); 
                    // return false to prevent normal browser submit and page navigation 
                    return false; 
                });
            }
        });
    }

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        theme: true,
        firstDay: 1,
        editable: false,
        events: "json-events.php?list=1&<?php echo $events_list; ?>",
        <?php if($_GET['page'] == 'home')
                echo "defaultView: 'agendaWeek',"; 
        ?>
        eventClick: function(event) {
            if (event.url) {
                window.open(event.url);
                return false;
            }
        },
        dayClick: function(date, allDay, jsEvent, view) {
            if (view.name == 'month') {
                $('#calendar').fullCalendar( 'changeView', 'agendaDay').fullCalendar( 'gotoDate', date );
            }else{
                if(allDay)
                {
                    var timeStamp = $.fullCalendar.formatDate( date, 'dddd+dd+MMMM_u');
                    var $eventDialog = $('<div/>').load("json-events.php?<?php echo $events_list; ?>&new=1&all_day=1&timestamp=" + timeStamp, null, EventLoad).dialog({autoOpen:false,draggable: false, width: 675, modal:true, position:['center',202], resizable: false, title:'Add an Event'});
                    $eventDialog.dialog('open').attr('id','eventDialog');
                }
                else
                {
                    var timeStamp = $.fullCalendar.formatDate( date, 'dddd+dd+MMMM_u');
                    var $eventDialog = $('<div/>').load("json-events.php?<?php echo $events_list; ?>&new=1&all_day=0&timestamp=" + timeStamp, null, EventLoad).dialog({autoOpen:false,draggable: false, width: 675, modal:true, position:['center',202], resizable: false, title:'Add an Event'});
                    $eventDialog.dialog('open').attr('id','eventDialog');;
                }
            }
        }
    });
});

The script json-events.php contains the form and also the code to process the data from the submitted form.

What happens when I test the whole thing:
– first user click on a day, then time of day. Popup opens with time and date indicated on the form. When user submits the form, dialog closes and calendar refreshes its events…. and the event added by the user appears several times (from 4 to up to 11 times!). The form has been processed several times by the receiving php script?!
– second user click, the popup opens, user submit empty form. Form is submitted (validate function not triggered) and user redirected to empty page json-events.php (ajaxForm not triggered either)

Obviously, my code is wrong (and dirty as well, sorry). Why is the submitted form, submitted several time to receiving script and why is the javascript function EventLoad triggered only once ?

Thank you very much for you help. This problem is killing me !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:44:27+00:00Added an answer on May 14, 2026 at 8:44 am

    UPDATE: I believe I am onto something, this link brought new lights to my problem. Below is the code that works fine with my application. It’s probably a bit dirty, but so far, my tests gave me good results.

    <script type='text/javascript'>
        // Calendar for all pages except for HOME
        $(document).ready(function() {
            $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                theme: true,
                firstDay: 1,
                editable: false,
                events: "json-events.php?list=1&<?php echo $events_list; ?>",
                <?php if($_GET['page'] == 'home')
                        echo "defaultView: 'agendaWeek',"; 
                ?>
                eventClick: function(event) {
                    if (event.url) {
                        window.open(event.url);
                        return false;
                    }
                },
                dayClick: function(date, allDay, jsEvent, view) {
                    if (view.name == 'month') {
                        $('#calendar').fullCalendar( 'changeView', 'agendaDay').fullCalendar( 'gotoDate', date );
                    }else{
                        if(allDay)
                        {
                            var timeStamp = $.fullCalendar.formatDate( date, 'dddd+dd+MMMM_u');
                            var $eventDialog = $('<div/>').load("json-events.php?<?php echo $events_list; ?>&new=1&all_day=1&timestamp=" + timeStamp, null, validForm).dialog({
                            autoOpen:false,
                            draggable: false, 
                            width: 675, 
                            modal:true, 
                            position:['center',202], 
                            resizable: false, 
                            title:'Add an Event',
                            buttons: {
                                'Add an Event': function() {
                                        var options = { 
                                            success: function() {
                                                $('#eventDialog').dialog().empty().remove();
                                                $("#addEvent").empty().remove();
                                                $('#calendar').fullCalendar( 'refetchEvents' );
                                            } 
                                        }; 
                                        // Manually trigger validation
                                        if ($("#addEvent").validate().form() == true) {
                                            $('#addEvent').ajaxSubmit(options);
                                            $('#eventDialog').dialog('close');
                                        }
                                },
                                Cancel: function() {
                                    $("#addEvent").empty().remove();
                                    $(this).dialog().empty().remove();
                                }
                            }
                            });
    
                            //$eventDialog.dialog('open').attr('id','eventDialog');
                            $eventDialog.dialog('open', {
                                open: function(event, ui) { $validForm; }
                            }).attr('id','eventDialog');
                        }
                        else
                        {
                            var timeStamp = $.fullCalendar.formatDate( date, 'dddd+dd+MMMM_u');
                            var $eventDialog = $('<div/>').load("json-events.php?<?php echo $events_list; ?>&new=1&all_day=0&timestamp=" + timeStamp, null, validForm).dialog({
                            autoOpen:false,
                            draggable: false,
                            width: 675,
                            modal:true,
                            position:['center',202],
                            resizable: false,
                            title:'Add an Event',
                            buttons: {
                                'Add an Event': function() {
                                        var options = { 
                                            success: function() {
                                                $('#eventDialog').dialog().empty().remove();
                                                $("#addEvent").empty().remove();
                                                $('#calendar').fullCalendar( 'refetchEvents' );
                                            } 
                                        }; 
                                        // Manually trigger validation
                                        if ($("#addEvent").validate().form() == true) {
                                            $('#addEvent').ajaxSubmit(options);
                                            $('#eventDialog').dialog('close');
                                        }
                                },
                                Cancel: function() {
                                    $("#addEvent").empty().remove();
                                    $(this).dialog().empty().remove();
                                }
                            }
                            });
    
                            //$eventDialog.dialog('open').attr('id','eventDialog');
                            $eventDialog.dialog('open', {
                                open: function(event, ui) { $validForm; }
                            }).attr('id','eventDialog');
                        }
                    }
                }
            });
    
            function validForm(){
                $("#addEvent").validate({
                    rules: {
                        calendar_title: "required",
                        calendar_url: {
                            required: false,
                            maxlength: 100,
                            url: true
                        }
                    },
                    messages: {
                        calendar_title: "Title required",
                        calendar_url: "Invalid URL format"
                    }
                });
            }
        });
    </script>
    

    Thanks again for taking the time to help me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.