Text Box Clear Button Error Using IE 10 (or later) in Compatibility View

Apr 10, 2015 at 6:49 PM
I ran across the following problem today: My browser is IE11. In this version (as with IE10), all "input" text elements are rendered with a pseudo-element to clear the contents (an "X" that shows up in the right end of the input element when the element has the focus). Also, select elements that would normally be rendered as a complex select (>20 items) are instead rendered as simple select elements. All is well until you go into "Compatibility View." In that configuration, the complex select elements are rendered as complex with the same clear button as all of the other input elements. Using the clear button does not update the related optHid value of the select element. So, when you save the record, the integer value of the complex selector is not set to 0 as it should be.

I created a utility function to "fix" the complex select elements to force the update. I run it on DocumentReady. It looks like this.
function FixComplexSelectClearButtons() {
    $("input.ms-lookuptypeintextbox").each(function() {
        var ctlSelector = $().SPServices.SPDropdownCtl({displayName: $(this).attr("Title")});
        ctlSelector.Obj.bind("blur", (function() {
            if(ctlSelector.Obj.val() == "") {
                ctlSelector.optHid.val(0);
            }
        }));
    });
}
So, has anyone dealt with this before me? Do you have a better solution? Am I missing anything here? If this is the best solution, maybe Marc could add it to SPServices? I'm open to suggestions.

Geoff
Coordinator
Apr 29, 2015 at 10:05 PM
This sounds like a SharePoint bug rather than an SPServices bug? Does the issue occur when there's no call to SPServices at all?

M.
Apr 30, 2015 at 11:51 AM
Edited Apr 30, 2015 at 1:55 PM
Oh, it's definitely not a bug in SPServices. This is all on Microsoft. I tested it on a new list with no modifications. The complex lookup behaves the same as described in my original post. If you clear the value of the complex lookup using the clear button in the text box then save the form, the old value is retained. The problem is, hitting the clear button does not result in a KeyDown event in the text box and the little down arrow next to the box wasn't clicked either. Those are the events that are required to update the optHid value. Since neither of those events occur, the value isn't updated. My suggestion was just a work-around to deal with the problem Microsoft created.

Geoff
Coordinator
Apr 30, 2015 at 1:57 PM
Got it. I'll see if I can report this one.

M.
Coordinator
Apr 30, 2015 at 1:57 PM
Oh, and what version of SharePoint is this?
Apr 30, 2015 at 5:30 PM
I'm on MOSS 2007.
Coordinator
Apr 30, 2015 at 5:37 PM
Ok, then you're probably stuck with the issue. I don't think they are "maintaining" MOSS anymore.

M.
Apr 30, 2015 at 5:54 PM
Aaahh, good point. I just tested in SP2010 and my lookups are being rendered as simple selects in IE11 regardless of the number of items in the lookup list and regardless of Compatibility View settings. No worries, the workaround I wrote for my 2007 site collection is working for me for now. Thanks.

Geoff