Mych
Mych

Reputation: 2553

How to generate FullCalendar from button click

All documentation I've seen loads AR Shaws FullCalendar on Document.Ready as so....

$(document).ready(function() {

    // page is now ready, initialize the calendar...

    $('#calendar').fullCalendar({
       // my options and callbacks here
    })

});

On one particular page I am offering the user the ability to select what events will be rendered by offering a set of cascading dropdowns. Only after all the dropdowns are set do I want to generate the calendar. So I have a button which will run a client script to check that the dropdowns all have values selected and if OK I then want the calendar to generate. I already have code in the options section that grabs the values of the dropdowns and uses that to get the event that match the criteria.

My button onClick code is...

function butGenCal() {
    // code to check dropdownlists
    // if pass then I call
    genCalendar();
    // else I show error message
}

My genCalendar code is...

function GenCalendar() {
    (function() {
      $('#calendar').fullCalendar({
          // my options and callbacks here
      })

    });
}

Unfortunately this does not work... no errors showing either. Any help appreciated.

Upvotes: 1

Views: 1969

Answers (2)

SREE NUNNA
SREE NUNNA

Reputation: 23

write a timeout function

setTimeout(function(){
              GenCalendar();
          },1000);

Upvotes: 0

MarCrazyness
MarCrazyness

Reputation: 2182

I was able to get it to work: http://jsfiddle.net/marcrazyness/98bu7/

I think the issue in your case might be the parenthesis and extra function definition:

function GenCalendar() {
      $('#calendar').fullCalendar({
          // my options and callbacks here
      });
}

Upvotes: 1

Related Questions