Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ui autocomplete adding a span

I am using jQuery autocomplete on a div but I am getting this extra span added automatically by jquery

"<span role="status" aria-live="polite" class="ui-helper-hidden-accessible">search test</span>"

How can I prevent this span from being created?

like image 297
user391986 Avatar asked Oct 09 '12 02:10

user391986


3 Answers

I solved it by adding a CSS rule:

.ui-helper-hidden-accessible { display: none; }
like image 160
user706420 Avatar answered Nov 11 '22 03:11

user706420


It's for accessibility reason, blind people can 'read' how much results are find. If you really want to delete this, you can modify the source code:

this.liveRegion = $( "<span>", {
                role: "status",
                "aria-live": "polite"
            })
            .addClass( "ui-helper-hidden-accessible" )
            .insertAfter( this.element );

But it's not recommended.

like image 6
jiguang Avatar answered Nov 11 '22 03:11

jiguang


I was using CSS flex box for layout with nth-child selectors, so, this span distorted my column layout.

display: none or position: absolute; top: -999999 won't resolve my problem. I had to remove the element from the DOM altogether, so, I wrote the following create event handler:

create: function (e)
{
    e.target.parentElement.removeChild(e.target.parentElement.querySelector(".ui-helper-hidden-accessible"));
}
like image 1
Ashraf Sabry Avatar answered Nov 11 '22 03:11

Ashraf Sabry