views:

163

answers:

3

I am using jquery autocomplete , and I've set these vars

$("#some_id").autocomplete("search.php?in=somewhere", {
        width: 270,
        selectFirst: false
});
$('#some_id').setOptions({max: 5});

As you can see it returns 5 list items ( results ) , and I want to add sixth list item where should be shown some text and how many results are exist except this 5 .

How do I do that ?

A: 

You'll need to modify the actual plugin to do that...

Ariel
But I have not got any clue , where and what part of code need to modify , can you say my on which function do I work in jquery.autocomplete.js
Artyom Chakhoyan
You'll have to read through the code and figure out what needs modifications... There's no simple way to do this (unless you can find a plugin that already does that)
Ariel
+2  A: 

It is probably going to require an edit around this function.

    function fillList() {
        list.empty();
        var max = limitNumberOfItems(data.length);
        for (var i=0; i < max; i++) {
            if (!data[i])
                continue;
            var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
            if ( formatted === false )
                continue;
            var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
            $.data(li, "ac_data", data[i]);
        }
        // INSERT YOUR ADDITIONAL ENTRY HERE... 
        listItems = list.find("li");
        if ( options.selectFirst ) {
            listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
            active = 0;
        }
        // apply bgiframe if available
        if ( $.fn.bgiframe )
            list.bgiframe();
    }
sberry2A
+2  A: 

Thanks a lot ! Here is what I did

function fillList() {
  list.empty();
  var max = limitNumberOfItems(data.length);
  for (var i=0; i < max; i++) {
   if (!data[i])
    continue;
   var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
   if ( formatted === false )
    continue;
   var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
   $.data(li, "ac_data", data[i]);
  }

  listItems = list.find("li");

  //////////////////////////// TOM //////////////////////////////////////////////////////////////////////////////////
  if( data.length > 5 ){ 
   if( (data.length-5) == 1 ){
    listItems[4].innerHTML +='<div style="position:absolute; top:127px; left:0px; width:260px;text-align:right;" >'+(data.length-5)+' item isn\'t shown</div>';
   }
   else{
    listItems[4].innerHTML +='<div style="position:absolute; top:127px; left:0px; width:260px;text-align:right;" >'+(data.length-5)+' items aren\'t shown</div>';
   }
  }
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if ( options.selectFirst ) {
   listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
   active = 0;
  }
  // apply bgiframe if available
  if ( $.fn.bgiframe )
   list.bgiframe();
 }
Artyom Chakhoyan