Jahid Hasan Jahid Hasan - 5 months ago 28
Javascript Question

I want to link matching text using easy autocomplete jquery plunging

Hi guys I face a problem with easy autocomplete jquery plunging.

I have successfully installed this in my site but I have a simple issue.
i want link this
I want link this with a external herf link.When user type and click here the go to the external.



//Enable description function
var options = {
url: "json/linked.json",

getValue: "text",

template: {
type: "links",
type: "description",
fields: {
link: "website-link",
description: "realName"
}
},

theme: "bootstrap"
};

$("#sheroes").easyAutocomplete(options);

[
{
"text": "Home",
"realName": "Jahid Hasan",
"website-link": "http://localhost/test/test.php"
},
{
"text": "Guide",
"website-link": "http://localhost/test/test.php"
},
{
"text": "Themes",
"realName": "Bruce Wayne",
"website-link": "http://localhost/test/test.php"
},
{
"text": "Examples",
"website-link": "http://localhost/test/test.php"
},
{
"text": "Download",
"website-link": "http://localhost/test/test.php"
},
{
"text": "Github",
"website-link": "http://localhost/test/test.php"
}
]





how i can do it.
Advance thanks

Answer

Just call window.open method, when user will change the text.

$("#sheroes"). change( function(){ 
  $.getJSON("result.json", function(data){ 
     $.each(data, function(i){
       if(data[i].text==$("#sheroes").val()) {
          window.open(data[i].website_link); 
       } 
     }); 
   }); 
});