Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

input created with weird values #113

Open
hodshemtov opened this issue Sep 27, 2017 · 0 comments
Open

input created with weird values #113

hodshemtov opened this issue Sep 27, 2017 · 0 comments

Comments

@hodshemtov
Copy link

hodshemtov commented Sep 27, 2017

Hi,
I use jquery ui autocomplete.
occasionally for some users the page load and the autocomplete input field init with weird values, like e_16K7 or e_0cbp or _e_0WfF
I believe it is somehow related to the initialization of the autocomplete in a specific scenario or to chrome extensions and/or autofill form plugins.

any ideas?

        $that.autocomplete({

            source: function (request, response) {
                $.ajax({
                    contentType: "application/json; charset=utf-8",
                    url: "/services/site_service.svc/.../autocomplete/.../" + request.term,
                    async: true,
                    success: function (data) {
                        var parsed = jQuery.parseJSON(data.data);

                        response($.map(data.data, function (obj) {
                            return {
                                label: obj.name,
                                labelLng: obj.nameLng,
                                labelLat: obj.nameLat,
                                labelShort : obj.ShortName,
                                value: obj.id,
                                type: obj.type,
                            };
                        }))
                    },
                    error: function (result) {
                        alertsCtrl.infoTitle(globalResources.errorMessageTitle, globalResources.generalservermessage, 3000);
                    }
                });
            },

            open: function (event, ui) { 
                // disable arrowNavigation while open
                $that.unbind("keydown", obsEcelObj.arrowNavigation);

                var results = $(this).autocomplete("widget")[0];
                if (results.childElementCount == 1) {
                    $(results.firstChild).trigger("click");
                    $(this).autocomplete("close");
                }
            },
            
            close: function (event, ui) {
                // enable arrowNavigation on close
                $that.keydown(obsEcelObj.arrowNavigation);
            },

            select: function (event, ui) {
                event.preventDefault();
                $that.val(ui.item.labelShort);
                $that.data("name", ui.item.labelShort);
                $that.data("value", ui.item.value);
                $that.data("type", ui.item.type);
                $that.attr("title", ui.item.labelLng);
                $that.removeClass("Error");
                $that.siblings("a.input_species").hide();

                $that.data("dirty2", "not"); 
            },
            focus: function (event, ui) {
                event.preventDefault();
                $that.val(ui.item.label);
            },
            
            minLength: 2
        }).data("uiAutocomplete")._renderItem = function (ul, item) {
            return $("<li data-value='" + item.value + "' data-type='" + item.type + "' data-name='" + item.label + "'>")
              .append("<a>" + item.label + "</a>")
              .appendTo(ul);
        }
    },
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant