javascript - CLNDR - how to pass event info to a separate DIV? -
i putting page use clndr plugin (http://kylestetz.github.io/clndr/), jquery plugin ('clndr.js') creating custom calendars.
the page .html page inserted javascript .php file. have use .php our server not run php codes in .html files.
the 'clndr.js' uses 'moments.js', 'underscore.js' , file 'site.js' provided kylestetz plugin. 'site.js' contains event information (dates events used in calendar generated 'clndr.js') in array this:
var eventarray = [ { date: '2015.07.25', title: 'artpolis kick-off', location: ' ott. 2.', url: 'esemeny/esemeny_reszletes_150535_01.html', type: 'holiday' }, { date: '2015.06.25', title: 'smartpolis kick-off', location: ' sztnh, bp., garibaldi u. 2.', url: 'esemeny/esemeny_reszletes_150535_01.html'}, { date: '2015.05.26', title: 'Űr-lÉptÉk ', location: 'bme k ép. díszterem ', url: 'esemeny/ ' }, { date: '2015.05.21', title: 'smart city tagozat', location: ' bme v1 ép. neumann tárgyaló.', url: 'esemeny/ ' }, { date: '2015.02.13', title: 'h-space 2015 ', location: ' bme ép. előadó.', url: 'esemeny/ ' }];
this 'site.js' file defines put calendar:
(sorry, can make code formatting work, not)
calendars.clndr2 = $('.cal2').clndr({ template: $('#template-calendar').html(), events: eventarray,
- this javascript use in head part of .php file insert .html file containing calendar:
(sorry, can make code formatting work, not)
<script> $(function(){ $("#includedcontentcalendar").load("../test-clndr-example.html"); });
and in body part:
<div class="col-sm-3 col-md-3 col-lg-3"> <h2>calendar</h2> <div id="includedcontentcalendar"></div> </div>
clndr has click event in 'site.js' file can used pass event information stored in array browser console:
clickevents: { click: function(target) { console.log(target); } },
now, clickevents display event information on .html page, in separate
<div id="event information">
. here event information shown when date clicked has event attached in array.
i did not find description in "manual", , directed forum github.
can please advise how pass event information stored in 'site.js' specific div id in .html file?
the click
handler given variable target
contains array of events
(it possible have more 1 event).
here example on how title of first event , set div:
click: function(target) { var info = target.events[0].title; $("#event-information").text(info); }
note: can't have spaces in id
, used <div id="event-information">
instead.
demo: http://jsfiddle.net/alan0xd7/yfl9njce/
update:
here example on how work url
, making links:
click: function(target) { var title = target.events[0].title; var url = target.events[0].url; var link = $("<a>"); // create link tag link.text(title); // set title link.attr("href", url); // set url $("#event-information").html(link); }
note used .html()
time, inserting html code (as opposed of text last time).
Comments
Post a Comment