Twitter bootstrap bootstrap-typeahead.js v2.3.2从建议的选项中选择选项并在新选项卡中打开

Twitter bootstrap bootstrap-typeahead.js v2.3.2从建议的选项中选择选项并在新选项卡中打开,twitter-bootstrap,typeahead.js,Twitter Bootstrap,Typeahead.js,从建议的选项中,用户将选择选项右键单击并在新选项卡中打开 这样,用户将在新选项卡中打开多个链接 这是我的消息来源 [ {"field_name":"abc ","field_value":"10162"}, {"field_name":"xyz ","field_value":"10135"}, {"field_name":"pqr ","field_value":"10121"}, {"field_name":"test","field_value"

从建议的选项中,用户将选择选项右键单击并在新选项卡中打开

这样,用户将在新选项卡中打开多个链接

这是我的消息来源

  [
     {"field_name":"abc ","field_value":"10162"},
     {"field_name":"xyz ","field_value":"10135"},
     {"field_name":"pqr ","field_value":"10121"},
     {"field_name":"test","field_value":"10100"}
    ]
HTML

})

这是解决方案, Oveload typaward.js的render函数,并在下面的代码中添加了链接findLink

      $(".typeahead").data("typeahead").render = function (items) {

            var that = this

            items = $(items).map(function (i, item) {
               i   = $(that.options.item).attr('data-value', item)
               i.find('a').html(that.highlighter(item))

                //console.log("Link : "+Mapped[item]);
                // Link here (my answer)
               i.find('a').attr("href","<?php echo base_url();?>/index/"+Mapped[item]);

               return i[0]
            })

            items.first().addClass('active')
            this.$menu.html(items)
            return this

       };

在字体内容上添加超链接我会尽力让你们知道。我已经在我的源代码中添加了链接。但是当我右键单击我建议的选项时,右键单击不工作这对jquery ui是可能的吗?请同时显示HTML标记和javascript。您提供的代码似乎只是typeahead的源代码。为什么单击鼠标右键?
$(document).ready(function() {
        var Mapped = {};
        $(".typeahead").typeahead({

            source : function(query, process) {

                return $.getJSON(
                        this.$element.attr('data-url'),
                        {query: query},
                function(result) {
                    var Labels = [];

                    $.each(result, function(i, item) {
                        Mapped[item.field_name] = item.field_value
                        Labels.push(item.field_name)
                    });

                    return process(Labels);

                });

            },
            items     : 10,
            minLength : 2,
            matcher   : function(item) {
                //console.log(item);
                return item;
            },
            updater   : function(item) {
                //For the Label selected ( item ) get the value mapped from the mapping array and set it to hidden element
                //$('hiddenelment').val(countryMapped[item]);
                var hidden_id = this.$element.attr('data-hidden');
                $(hidden_id).val(Mapped[item]);

                return item;
            }
        });
      $(".typeahead").data("typeahead").render = function (items) {

            var that = this

            items = $(items).map(function (i, item) {
               i   = $(that.options.item).attr('data-value', item)
               i.find('a').html(that.highlighter(item))

                //console.log("Link : "+Mapped[item]);
                // Link here (my answer)
               i.find('a').attr("href","<?php echo base_url();?>/index/"+Mapped[item]);

               return i[0]
            })

            items.first().addClass('active')
            this.$menu.html(items)
            return this

       };