0

I am using Responsive Calendar Plug In which I need to dynamically create events.

How can I pass the arr event array as default event list to the plug in.

code is as follow.

enter image description here

Generated Event List is as follow

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
TED
  • 1,829
  • 5
  • 18
  • 36

2 Answers2

1

You are calling JSON.parse on a a string that isn't really JSON. It's just strings separated by colon. Your string should have the { } in it so that it will be parsed as a hash.

It should be var str = '{ "2014..." : ... }'

then events : JSON.parse(str)

DrLivingston
  • 788
  • 6
  • 15
  • yes correct but I need this way not really json (I have updated my question) – TED Feb 28 '14 at 09:52
  • Why create a string only to parse it? You don't need to jump through all those hoops. Just have your PHP code write the map directly: `var events = {};` `events["2014-03-03"] = {"number" : 5, }` ... – DrLivingston Mar 05 '14 at 08:02
0

Try the following:

$(".responsive-calendar").responsiveCalendar({
    time: '2013-05',
    events: JSON.parse(arr),
});
M Reza Saberi
  • 7,134
  • 9
  • 47
  • 76