in Education by
I have converted a few DropDownLists to jQuery comboboxes to add auto complete functionality etc. however, there are various methods in the codebehind file to disable the drop down lists. This does not disable the jQuery combobox so the value can still be changed. Is there a way to bind the combobox to the dropdown list enable / disabled event? so they can update automatically based on the source drop down list? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Ok, I think I have come up with a solution by editing the js file for creating the combo box - you may recognise most of the script to turn in to a combo box. I have highlighted the added lines with ** ** at the beginning and end (I was trying to make it bold) (function ($) { $.widget("ui.combobox", { _create: function () { var self = this, select = this.element.hide(), selected = select.children(":selected"), value = selected.val() ? selected.text() : ""; **var disabled = select.is(':disabled');** var dropDownListID = this.element.context.id; var input = this.input = $(" ") .insertAfter(select) .val(value) .autocomplete({ delay: 0, minLength: 0, source: function (request, response) { var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); response(select.children("option").map(function () { var text = $(this).text(); if (this.value && (!request.term || matcher.test(text))) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1"), value: text, option: this }; })); }, select: function (event, ui) { ui.item.option.selected = true; self._trigger("selected", event, { item: ui.item.option } ); __doPostBack(dropDownListID, ''); }, change: function (event, ui) { if (!ui.item) { var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"), valid = false; select.children("option").each(function () { if ($(this).text().match(matcher)) { this.selected = valid = true; return false; } }); if (!valid) { // remove invalid value, as it didn't match anything $(this).val(""); select.val(""); input.data("autocomplete").term = ""; return false; } } } }) .addClass("ui-widget ui-widget-content ui-corner-left") **.attr('disabled', disabled)** .click(function () { $(this).select(); }); input.data("autocomplete")._renderItem = function (ul, item) { return $("") .data("item.autocomplete", item) .append("" + item.label + "") .appendTo(ul); }; this.button = $("") .attr("tabIndex", -1) .attr("title", "Show All Items") **.attr('disabled', disabled)** .insertAfter(input) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass("ui-corner-all") .addClass("ui-corner-right ui-button-icon") .click(function () { // close if already visible if (input.autocomplete("widget").is(":visible")) { input.autocomplete("close"); return; } // work around a bug (likely same cause as #5265) $(this).blur(); // pass empty string as value to search for, displaying all results input.autocomplete("search", ""); input.focus(); }); }, destroy: function () { this.input.remove(); this.button.remove(); this.element.show(); $.Widget.prototype.destroy.call(this); } }); })(jQuery);

Related questions

0 votes
    I have converted a few DropDownLists to jQuery comboboxes to add auto complete functionality etc. however, there ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have a simple MVC3 Controller Action like this [HttpGet] [OutputCache(Duration = 1200,Location=System.Web. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    When I select value in select2 multiple selection, the default 0 value is still there in the list. Any ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    We create new sites in IIS 6 (Windows Server 2003) using IIS Manager. When these sites are created ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    With a chrome plugin, I changed my timezone to +14. However, I saw that the calendar app is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have an ASP.NET MVC website. In my backend I have a table called People with the following ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have an issue refrerencing an assembly in a view for MVC. This namespace is part of a dll I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I have implemented exception handling as mentioned in below link How to pass error message to error view in ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have an issue refrerencing an assembly in a view for MVC. This namespace is part of a dll I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    The RangeValidator will fetch the value of the input and validate it with regex. Part of the regex is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    My thinking is that people use Docker to be sure that local environment is the same as production and that ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 12, 2022 in Education by JackTerrance
0 votes
    i am using serilog in asp net core application and using a json formatter to create a daily log file ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I'm fairly new to Razor Components and I would like to change the title and other data inside the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I created a brand new Web Application, .NET Full Framework 4.7.2, added Application Insights Snapshot ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have a AWS API Gateway, deployed using SAM template. The API request comes to the Proxy Lambda Function ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
...