I'am working on a project and am trying to use YUI Library to filter the result in a list by typing a filter word, the probleme is that somtimes this work fine other times it's just break down saying : Uncaught Error: No inputNode specified.
this is my JS function :
YUI(YUI3_config).use('autocomplete-base', 'autocomplete-filters', function (Y) {
// Create a custom PieFilter class that extends AutoCompleteBase.
var PieFilter = Y.Base.create('pieFilter', Y.Base, [Y.AutoCompleteBase], {
initializer: function () {
this._bindUIACBase();
this._syncUIACBase();
}
}),
// Create and configure an instance of the PieFilter class.
filter = new PieFilter({
inputNode: '#ac-input20',
minQueryLength: 0,
queryDelay: 0,
source: (function () {
var results = [];
Y.all('#list31 > .list31, #list31 > .list32').each(function (node) {
results.push({
node: node,
tags: node.getAttribute('data-tags')
});;
});
return results;
}),
resultTextLocator: 'tags',
resultFilters: 'phraseMatch'
});
filter.on('results', function (e) {
Y.all('#list31 > .list31, #list31 > .list32').addClass('hidden');
Y.Array.each(e.results, function (result) {
result.raw.node.removeClass('hidden');
});
}); });
and this is my HTML :
<div id="play30" class="liste-donnees block ezcca-edit-datatype-ezdate">
<fieldset>
<legend>
<span class="long-legend-wrap">Ressources
<span class="classattribute-description"></span>
</span>
</legend>
<div style='width: 400px;'>
<label for="ac-input20">Filtre:</label>
<input id="ac-input20" type="text">
<ul id="list31" class="liste-gauche"></ul>
</div>
<p style='float: left;margin-top: 150px;font-weight: bold'>=====></p>
<ul id="list32" class="liste-droite"></ul>
</fieldset>
any ideas, thanks for your help in advance
答案 0 :(得分:1)
通常,“没有指定inputNode”。无法找到指定的输入(即'#ac-input20')时抛出错误。
Obyously这听起来很愚蠢,因为它已在您的HTML中声明;发生错误时,您是否检查了HTML源以确保'ac-input20'元素存在?
此外,您的目标是'#list31&gt; .list31'元素但是在你的HTML中,没有元素有一个名为'list31'的类。
希望这会有所帮助。