robmonie / jquery-week-calendar

Now actively maintained in the following fork - https://github.com/themouette/jquery-week-calendar
388 stars 388 forks source link

render different events on click function on jquery week calendar without reloading the page #55

Open Assdi opened 8 years ago

Assdi commented 8 years ago

Any one please help I want to render different events on week calendar how can i do that here is code of two click functions which is calling function that contain demo.js code

$(document).ready(function() { $("#1st").click(function(){

  var year = new Date().getFullYear();
  var month = new Date().getMonth();
  var day = new Date().getDate();

data= [
        {
           "id":1,
           "start": new Date(year, month, day, 12),
           "end": new Date(year, month, day, 13, 30),
           "title":"Lunch with Mike"
        },
        {
           "id":3,
           "start": new Date(year, month, day + 1, 17),
           "end": new Date(year, month, day + 1, 17, 45),
           "title":"Hair cut"
        }]

        asad(data);
});

$("#2nd").click(function(){
    $('#calendar').empty();
    var year = new Date().getFullYear();
  var month = new Date().getMonth();
  var day = new Date().getDate();

    data=[{
           "id":5,
           "start": new Date(year, month, day + 1, 14),
           "end": new Date(year, month, day + 1, 15),
           "title":"Product showcase"
        },
        {
           "id":6,
           "start": new Date(year, month, day, 10),
           "end": new Date(year, month, day, 11),
           "title":"I'm read-only",
           readOnly : true
        } ]

    asad(data);
    })

});

function asad(data) {

demo file code here

}