1

I have a full calendar functionality with some events generated from a json file. The events have lengthy names. So I want to cut it by using substring(0,3) functionality. I want to use this substring function in title of the event. Where should i add substring to get ... after some 4 characters.

$('#calendar').fullCalendar({
//$.fn.popover.defaults.container = 'body';
            header: {
                left: 'prev,next',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            contentHeight: 300,
            height: 200 ,
            eventRender: function(event, element) {
                element.popover({
                    title: event.title,
                    placement: 'auto',
                    html: true,
                    trigger: 'hover',
                    animation:'true',
                    content: event.msg,
                    container: 'body'
                });
                $('body').on('click', function(e) {
                    if (!element.is(e.target) && element.has(e.target).length === 0 && $('.popover').has(e.target).length === 0)
                        element.popover('hide');
                });
            },
            events: eventData[i].title.substring(0,5)+'..' // not working substring function
        });
2
  • Do mean something like this str.substring(3, 4) ? It will take 4 chars from the third char..
    – Bla...
    Aug 12, 2014 at 12:49
  • @user26409021 yes like this only.. how to implement in events ?
    – arjun
    Aug 12, 2014 at 12:59

1 Answer 1

0

Can't you just use some CSS to achieve this?

.popover-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

Unless the title is really long (like >200 characters), in which case, you might want to truncate it at the source first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.