سؤال

As am totally new to YUI i dont have any clue about.I have just gone through this link to implement autocomplete using YUI http://developer.yahoo.com/yui/autocomplete/.

According to my requirement i need to assign a string array dynamically to datasource object instead of var dsLocalArray = new YAHOO.util.LocalDataSource(["apples", "broccoli", "cherries"]); something like

var dsLocalArray=new YAHOO.util.LocalDataSource(documentList[]);

where my documentList is String Array.How do i that?Thanks in advance for the help.

هل كانت مفيدة؟

المحلول

I would suggest you to use YUI3 than YUI2, the example you are showing which uses the YAHOO namespace which is YUI2.

YUI3 is simpler and better, you can get the docs here: http://yuilibrary.com/yui/docs/autocomplete/

Example of implementing with YUI3 including highlighting feature:

YUI().use('autocomplete', 'autocomplete-filters', 'autocomplete-highlighters', function (Y) {
  Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
    resultFilters    : 'phraseMatch',
    resultHighlighter: 'phraseMatch',
    source           : ['Alabama','Alaska','Arizona','Arkansas','California']
  });
});

Try to lok into the examples at the right bottom side panel in the above docs link.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top