我已经将一个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);
},
...
});我注意到以下与年报相关的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的使用引起的。
发布于 2013-01-16 23:46:45
这让我想起了..。
在1.2.5版本中,Class得到了相当大的改进。而不是先做原型,然后调用implement / extend,现在您可以将它们作为mutators来执行
Autocompleter.Base = new Class({
Implements: [Options, Events],
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.Local = new Class({
Extends: Autocompleter.Base
});您应该阅读有关从1.11迁移到1.2.5的一些指南/教程。1.2.5实际上现在不是一个好的发行版,它已经有2.5年的历史了,目前由于https://bugzilla.mozilla.org/show_bug.cgi?id=789036的原因在FireFox 18中被打破了
请参阅现在编写类的一些教程,如http://fragged.org/tutorial-write-a-small-content-slider-class-in-mootools-and-extend-it_1321.html等
https://stackoverflow.com/questions/14355950
复制相似问题