trigger javascript from jquery autocomplete

Lets assume I have a javascript method called createrow(dt, table)

I would like to call that when a user selects an item in my jquery autocomplete.

Ultimately what I need to do  is actually create a row in my jquery datatable when this happens..but I will make this function call do that  ....

Can someone help me with wiring this up..assuming the  method createrow(dt,table)

Here is my autocomplete code in my view in the scrips section

 $(".caAutoComplete_EntityEntityNameSearch").autocomplete(
        {
            source: "@Url.Content("~/Shared.mvc/EntityEntityNameSearchAuto")",
            minLength: 3,
            select: function (event, ui) {
                var inputlabel = ui.item.label;
                var inputvalue = ui.item.value;
                $("#hdnClientId").val(inputlabel);

             return false;
            }
        });

Open in new window


Here is where I use it in html:

<div id="main-container" class="container-fluid">
    <div class="col-xs-12">
        <div class="row" style="margin-bottom:4px;">
            <div class="col-md-1">
                <span style="font-size:11pt;font-weight:bold;">Entity Name:</span>
            </div>
            <div class="col-md-2">
                @Html.TextBoxFor(x => x.SearchEntityNameOrId, new { @type = "text", @placeholder = "Search", @class = "caAutoComplete_EntityEntityNameSearch", @style = "width:100%!important;" })
            </div>

        </div>
    </div>

Open in new window

LVL 11
Robb HillSenior .Net DeveloperAsked:
Who is Participating?
 
leakim971PluritechnicianCommented:
you may do this call inside your select function or response one
http://api.jqueryui.com/autocomplete/#event-response
http://api.jqueryui.com/autocomplete/#event-select

select: function (event, ui) {
    // put you call here

Open in new window

or :
response: function (event, ui) {
    // put you call here

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.