javascript - jQuery/JS – Outputting objects inside an array – best practice -
need advice. using jquery calendar plugin (which seems rare!) , initialised js. no html.
to add together events, have write each event object within array:
events: [ { title: "title of event", start: { date: yyyymmdd or "yyyymmdd", // "20131230" time: "hh.mm" // "12.00" }, end: { date: yyyymmdd or "yyyymmdd", // "20131230" time: "hh.mm" // "20.00" } }, { title: "title of event", start: { date: yyyymmdd or "yyyymmdd", // "20131230" time: "hh.mm" // "12.00" }, end: { date: yyyymmdd or "yyyymmdd", // "20131230" time: "hh.mm" // "20.00" } } ], i using django, , need write loop each event format. so, question is, what's best way this? json? possible? best practice output info js objects?
thanks in advance,
r
as required @rdck, below illustration how can achieved :
server side (php example) :
<?php $arr = array(); $arr[] = array( 'title'=>'title of event', 'start' => array( 'date'=>'yyyymmdd', 'time'=>'hh.mm' ), 'end' => array( 'date'=>'yyyymmdd', 'time'=>'hh.mm' ), ); $arr[] = array( 'title'=>'title of event2', 'start' => array( 'date'=>'yyyymmdd', 'time'=>'hh.mm' ), 'end' => array( 'date'=>'yyyymmdd', 'time'=>'hh.mm' ), ); ?> in html
<script type="text/javascript"> var events = '<?php echo json_encode($arr); ?>'; </script> events json object can pass straight events calendar
javascript jquery json django
No comments:
Post a Comment