asp.net mvc4

Hi Guys,

I have implemented progress bar for my code in order to let users have some indication what is going on behind the screen.

this is my jquery code for progress bar:

 $(document).ajaxStart(function () {
                $("#WaitDialog").dialog('open');
            }).ajaxStop(function () {
                $("#WaitDialog").dialog('close');
            }).ajaxSuccess(function () {
            });


 $("#WaitDialog").dialog({
                draggable: false,
                autoOpen: false,
                resizable: false,
                modal: true
            });

            

Open in new window


The issue:

After I added the progress bar it effected my autocomplete function. when users type the progress bar popup every second. actually when users type to the search box the autocomplete jquery function is going to the controller back and ford.

here is my autocomplete function:

 var performSearch = true;
            $("#searchTxt").autocomplete({
                source: function (request, response) {
                    if (performSearch) {
                        $.ajax({
                            url: '@Url.Action("GetAutocompleteResults", "Purchase")',
                            dataType: "json",
                            data: {
                                searchTxt: $("#searchTxt").val(),
                                option: $("#SearchByOptions").val(),
                                deptid: $("#deptid").val(),
                                catid: $("#catid").val()
                            },
                            success: function (data) {
                                response(data);
                                $("#searchTxt").focus();
                            },
                            error: function (jqXHR, textStatus, errorThrown) {
                                alert(errorThrown);
                                $("#searchTxt").focus();
                            }
                        });
                    }
                },
                minLength: 3,
                delay: 2,
                minChars: 3,
                matchSubset: 1,
                matchContains: 1,
                cacheLength: 10,
                autoFill: true
            }).keydown(function (event) {
                if (event.keyCode == 8) {
                    performSearch = false;
                } else {
                    performSearch = true;
                }
            }).data('autocomplete')._renderItem = function (ul, item) {

                try {
                    var opt = $("#SearchByOptions").val();
                    var txt = '<a><b>ItemLookupCode: </b>' + item.ItemLookupCode +
                        ' <b>Suplier: </b>' + item.SuplierName +
                        ' <b>Department: </b>' + item.DepartmentName +
                        ' <b>Category: </b>' + item.CategoryName + '<br></a>';

                    item.label = txt;

                    if (opt == "1" || opt == "0")
                        item.value = item.ItemLookupCode;
                    else if (opt == "2")
                        item.value = item.Description;
                    else if (opt == "3")
                        item.value = item.SubDescription1;
                    else if (opt == "4")
                        item.value = item.SubDescription2;
                    else if (opt == "5")
                        item.value = item.SuplierName;
                }
                catch (err) {
                    alert(err);

                }
                return $('<li></li>')
                    .data('item.autocomplete', item)
                    .append(item.label)
                    .appendTo(ul);
            };

Open in new window


My question is - how do I disable or stop the progress bar to run when I type in the textbox and query the autocomplete.

Thanks.
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

louisfrCommented:
To prevent global events from trigerring, call ajax with the global option set to false:
$.ajax({
    global: false,
    ........
});

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Moti Mashiah.NET DeveloperAuthor Commented:
solved
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.