Skip to content Skip to sidebar Skip to footer

Asp.net Form Reload Forced From Javascript Conflicts With Jquery Autocomplete Textbox Fillup?

I defined an ASP.NET form where I have, among many others, the following form elements: a TextBox, an HiddenField and a DropDownList defined like this: select event. The selected value is written to the form field by jQuery UI after the select event, but this code never runs. The .closest("form").submit() reloads the page immediately. At this point, the autocomplete field still only contains what the user had typed.

The quick and dirty solution to this is to send the form after a short delay, to give the other events a chance to finish.

// ... select: function (event, ui) {
    var _data = ui.item,
        _value,
        $form = $(this).closest("form");

    // calculate _value ...

    $("input[id$='_hdnData ']").val(_value);

    setTimeout(function () { $form.submit(); }, 50);
}

Post a Comment for "Asp.net Form Reload Forced From Javascript Conflicts With Jquery Autocomplete Textbox Fillup?"