且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何基于Jquery Mobile中的事件名称更改日历中特定日期的背景图像?

更新时间:2023-01-28 15:55:31

我已进行了一些修复,将根据事件添加自定义类.它需要对 jqm日历库进行一些小的更改.

I have made a little fix which will add custom classes based on event. It required doing some minor changes to jqm calendar library.

我首先制作了三个自定义背景CSS类.wedding.meeting.party.然后在调用.jqmCalender()的代码内添加一个值.

I first made three custom background CSS classes .wedding, .meeting and .party. And then added a value within the code where you call .jqmCalender().

下载工作示例

Download working example

$("#calendar").jqmCalendar({
  events: [{
      "summary": "Birthday Dinnaer",
        "begin": new Date(y, m, d + 10),
        "end": new Date(y, m, d + 11),
        "bg": "wedding" // or meeting or party "matches class name"
  }]


jqm calendar.js 中,我进行了以下更改


In jqm calendar.js, I made the following changes

// line 11
bg: "bg",

// line 119 - to retrieve the value from .jqmCalendar() function
var bg = event[plugin.settings.bg];

在这里,日期成为样式,但是我必须删除.importance以便不覆盖自定义类.

Here, the date gets the style but I had to remove .importance in order not to override the custom class.

// line 127
$a.append("<span>&bull;</span>").removeClass("importance-" + importance.toString()).addClass(bg);

在此处,当您单击日期时,它会为摘要添加相同的样式.

Here it adds the same style to summary when you click on date.

// line 211
$("<li class=" + bg + ">" + ((timeString != "00:00-00:00") ? timeString : "") + " " + summary + "</li>").appendTo($listview);


这是自定义类.


And here are the custom classes.

.wedding {
  background: #fcecfc;
}

.meeting {
  background: #f8ffe8;
}

.party {
  background: #ff3019;
}