| Issue 236: | Custom title layout depending on view | |
| 2 people starred this issue and may be notified of changes. | Back to list |
I would like to change event title fore each view I'm using. For example i would like to use a short 1 row title for month view, a medium length title with custom graphic on week view and a long length title with custom graphic on daily view. The problem is that I can't save multiple title formats for the same event cause I didn't find a way to store custom variables inside event objects. Does anyone know a way to do that withouth using a global variable that stores all titles for each event?
Dec 9, 2009
#1
renzo.la...@gmail.com
Dec 10, 2009
No other ways exist then?
It would be nice to just give custom attributes to events like
events: [
{
title: 'Jhon: Here is the first event',
custom-title: '<div style="background-color:red;font-weight:bold;">1st event</div>',
start: new Date(y, m, 1)
},
{
title: 'Bob: This is the second event',
custom-title: '<div style="background-color:green;font-weight:bold;">2nd event</div>',
start: new Date(y, m, d-5)
},
]
Unfortunately custom attributes like "custom-title" get lost when I try to call them
back.
Do you think it could be a nice feature?
Dec 10, 2009
These custom attributes don't get lost, they are still available in eventRender().
Use this example code:
events: [{
title: 'Title',
custom_title: 'Custom title',
[...]
}],
eventRender: function(calEvent, element, view) {
if(calEvent.custom_title) {
element[0].innerHTML = element[0].innerHTML.replace(calEvent.title,
calEvent.custom_title);
}
}
You might have to use a more sophisticated approach to replace your title from the
innerHTML - this is just an example.
Dec 10, 2009
What if you want to display both the title and custom_title? The code above just replaces title with custom_title.
Dec 10, 2009
Just have a look at the element[0].innerHTML and decide which part you want to have
replaced. Then it might look like this:
element[0].innerHTML = element[0].innerHTML.replace('</span></a>',
':'+calEvent.custom_title+'</span></a>');
Dec 18, 2009
Ok, I found my problem. The data is stored but I tried to read it from "element" instead of "calEvent" ;) Now it works ;)
Dec 19, 2009
glad you got it to work. yeah, eventRender is useful for doing all sorts of custom things that affect the way events are displayed. keep in mind that json property names like custom-title are invalid unless you put quotes around them, or use custom_title like you ended up doing
Status:
Done
|
|
| ► Sign in to add a comment |