views:

801

answers:

1

While using jQuery's autocomplete, I've noticed that characters & and ' are escaped as & and '

Example, autocomplete displays Barbara’s Straight Son but when I choose this the field shows Barbara's Straight Son.

Any ideas how I can avoid this?

Thank you for your time!

+1  A: 

you need to unescape the html entities. the easiest way i found to do that is to use this function:

var unescapeHtml = function (html) {
      var temp = document.createElement("div");
      temp.innerHTML = html;
      var result = temp.childNodes[0].nodeValue;
      temp.removeChild(temp.firstChild)
      return result;
  }

so pass your string through this function before it gets put into your input box. You might have to modify the autocomplete plugin in order to do this.

mkoryak