For a website, I will have a lot of auto complete fields on differents pages.
They works exactly the same on all pages, except they must not call the same url.
I was wondering if there is a possibility to mention the url on the <input> which is going to be an autocomplete field? The goal is to have one js code for many html codes
I tried something, but it doesn’t seems to works:
Html:
<input type="field" name="search" class="autocomplete" value="Search" url="smalltest/otherTest/..." />
And the JS
$(document).ready(function () {
$("input.autocomplete").autocomplete({
source: $(this).attr("url")
}); });
I got exception in jquery lib.
Change the url attribute to
data-urlthen in your .autocomplete do this:source: $(this).data("url")