【问题标题】:how to add substring functionality in full calendar using jquery?如何使用 jquery 在完整日历中添加子字符串功能?
【发布时间】:2014-08-12 12:41:30
【问题描述】:

我有一个完整的日历功能,其中包含一些从 json 文件生成的事件。这些事件的名称很长。所以我想通过使用 substring(0,3) 功能来削减它。我想在事件的标题中使用这个子字符串函数。我应该在哪里添加子字符串以获取 ... 在大约 4 个字符之后。

$('#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
        });

【问题讨论】:

  • 意思是这样的str.substring(3, 4) 吗?从第三个字符开始需要 4 个字符..
  • @user26409021 是的,只有这样......如何在事件中实现?

标签: jquery substring fullcalendar


【解决方案1】:

你不能只使用一些 CSS 来实现这一点吗?

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

除非标题真的很长(例如 >200 个字符),在这种情况下,您可能需要先在源处截断它。

【讨论】:

    猜你喜欢
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多