Hi all,
I was trying to customize the jQuery autocomplete plugin... I have to add a turn off button at the end of the result set returned. The problem is that I have added a button to the returned result set but when I click on the button the HTML of the button goes into the text box.... I hope I am making some sense... From what I understand I have to unbind the event for that ... I did some trial and error but no success :-( e.g.
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];
if (i == max-1 || i == max-2) {
***$li.unbind('click');***
}
The plugin stops working.....
Second experiment
list = $("<ul/>").appendTo(element).mouseover( function(event) {
if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
if (noResFlag != -1) {
active = $("li", list)
.removeClass(CLASSES.ACTIVE)
.index(target(event));
$(target(event)).addClass(CLASSES.ACTIVE);
}
}
}).click(function(event) {
if (noResFlag != -1) {
$(target(event)).addClass(CLASSES.ACTIVE);
select();
// TODO provide option to avoid setting focus again after selection?
// useful for cleanup-on-focus
input.focus();
}
return false;
}).mousedown(function() {
config.mouseDownOnSelect = true;
}).mouseup(function() {
config.mouseDownOnSelect = false;
}).mouseout(function(event){
$("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
return false;
});
var i1=$('li',list).size() ;
alert(i1);
$("li", list).each(function (i) {
if ((i == i1 -1) || (i == i1-2)) {
this.unbind('click');
}
});
if( options.width > 0 )
element.css("width", options.width);
needsInit = false;
here i1
always becomes zero...... :-(
thanks in advance... cheers abhi