duanbigan7765 2014-01-22 22:14
浏览 56

如何在jQuery自动完成UI中显示特殊字符?

Hi I'm trying to get special characters like ëéäá to show up in my autocomplete. For example the letter ë shows up as & # 2 3 5 ; (without the spaces).

I'm creating a php array which I json_encode. I can create the json with both ë (html_entity_decode) and & # 2 3 5 ; (without the spaces) in the object. When I create the json object with ë it doesn't show up in the autocomplete.

My autocomplete function looks as follow:

<script>
    $(document).ready(function() {
     $(function() {
     <?php echo "var availableCustomers = " . $this->searchCustomer . ";
"; ?>
     $( "#customerAutocomplete" ).autocomplete({
     delay: 0,
     source: availableCustomers,
     select: function(event, ui) {
        window.location.href = '/customer/look-customer/deb/' + ui.item.deb;
         }
      });
     });        
    });
</script>
  • 写回答

1条回答 默认 最新

  • dryl34156 2014-01-23 00:20
    关注

    Autocomplete allow you to manage the render of your element. You may start from this point and try to make a custom render function. You just have to specify a render function in the configuration like :

    $( "#customerAutocomplete" ).autocomplete({
        ... 
        _renderItem: function( ul, item ) {
            return $("<li>")
            .attr("data-value", item.value)
            .append($("<a>").html(item.label))
            .appendTo(ul);
        },
        ...
    });
    

    You can console.debug the item to check if it contains your text with accent.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分