我已将 Joomla 1.5 网站迁移到 Joomla 2.5。
Joomla 1.5 网站使用 Mootools 1.11。
Joomla 2.5 网站使用 Mootools 1.4.5。
该网站包含一个名为 annuary 的特定功能。
年鉴需要一些基于 Mootools 1.11 的 JavaScript 文件。
我需要将这些文件中的一些说明改编为 Mootools 1.4.5。
这些 JavaScript 文件之一是 Autocompleter.js。
这是 Autocompleter.js 的摘录:
var Autocompleter = {};
Autocompleter.Base = new Class({
...
initialize: function(el, options) {
this.setOptions(options);
this.element = $(el);
this.build();
this.observer = new Observer(this.element, this.prefetch.bind(this), $merge({
delay: 400
}, this.options.observerOptions));
this.value = this.observer.value;
this.queryValue = null;
},
...
});
Autocompleter.Base.implement(new Events);
Autocompleter.Base.implement(new Options);
Autocompleter.Local = Autocompleter.Base.extend({
...
initialize: function(el, tokens, options) {
this.parent(el, options);
this.tokens = tokens;
if (this.options.filterTokens) this.filterTokens = this.options.filterTokens.bind(this);
},
...
});
我注意到以下与 annuary 相关的 JavaScript 指令不再按预期工作:
new Autocompleter.Local(idChamp, tabValues, {
'delay': 100,
'injectChoice': function(choice) {
var el = new Element('li')
.setHTML(this.markQueryValue(choice[0]))
.adopt(new Element('span', {'class': 'example-info'}).setHTML(this.markQueryValue(choice[1])));
el.inputValue = choice[0];
this.addChoiceEvents(el).injectInside(this.choices);
}
});
执行 Autocompleter.Base 的初始化函数。
但是 Autocompleter.Local 的初始化函数不是。
有人可以解释一下为什么吗?
我确信问题是由使用 Mootools 1.4.5 引起的。