After .load() Reset Textbox with User Entered Value using JavaScript and jQuery

Posted by Aaron Salazar on Stack Overflow See other posts from Stack Overflow or by Aaron Salazar
Published on 2010-03-26T17:55:46Z Indexed on 2010/03/26 18:03 UTC
Read the original article Hit count: 226

Filed under:
|

My function below calls a partial view after a user enters a filter-by string into the text box '#DocId'. When the user is done typing, the partial view is displayed with filtered data. Since my textbox needs to be in the partial view, when user is done entering a filter-by string and is shown the filtered data, the textbox is reset and the user entered data is lost. How can I set the value of the textbox back to the user entered string after the partial view is displayed?

I'm pretty sure I need to use .val() but I can't seem to get this to work.

$(function() {
    $('#DocId').live('keyup', function() {
        clearTimeout($.data(this, 'timer'));
        var val = $(this).val();
        var wait = setTimeout(function() { $('#tableContent').load('/CurReport/TableResults', { filter: val }, 500) }, 500);
        $(this).data('timer', wait);
    });
});

Thank you,

Aaron

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript