2

I am using the below jquery code to call a ajax function in my contorller CS. Search is the function name. How ever the function is called in the controller. But i am supposed to get a value in the text box of the page inside this function. Basically this is for the auto complete feature. on key up the function is called. But i am not able to get the value in the textbox to do a relavent search. please reply back anything you feel would be helpful to me. Thanks in advance.

$(document).ready(function(){
    $("#searchusers").autocomplete("http://localhost/CS/index.php/search" , {
        width: 500,
        selectFirst: false
    });

});
$(document).ready(function(){
    $("#searchusers").result(function(event, data, formatted) {
        if (data)
            $(this).parent().next().find("input").val(data[1]);
    });
    $('#set1 *').tooltip();
    $('#firstname').tooltip();

});
0

1 Answer 1

2

You need to bind autocomplete to the input box:

$(document).ready(function(){
    $("#searchusers").parent().next().find("input").autocomplete("http://localhost/CS/index.php/search" , {
        width: 500,
        selectFirst: false
    });

});

If you give the input box its own id, the code becomes much clearer:

<input type="text" id="searchUsersInput">

Then:

$(document).ready(function(){
    $("#searchUsersInput").autocomplete("http://localhost/CS/index.php/search" , {
        width: 500,
        selectFirst: false
    });

});
$(document).ready(function(){
    $("#searchUsersInput").result(function(event, data, formatted) {
        if (data)
                $(this).val(data[1]);
    });
    $('#set1 *').tooltip();
    $('#firstname').tooltip();

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.