JQuery ui datepicker doesn't disappear in IE7 after selection

Got a jQuery UI datepicker plugin that works great, however when using IE7, the calendar doesn't disappear after you make a selection like in FF, Safari, etc.

Here's the url http://www.mchenry.edu/insideApp/OIRPprojectrequest/oirpprojectrequestform.aspx

Hope this is something silly, "IE7 is the only browser I need to support internal clients.

Thnx!

EDIT: try this url, http://www.mchenry.edu/test/oirpprojectrequestform.aspx

Sorry it!

+2


source to share


3 answers


Web page error details

User agent: Mozilla / 4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident / 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Mon 21 Sep 2009 18: 50:51 UTC

Message: 'length' is null or is not an object Line: 139 Char: 17 Code: 0 URI: http://www.mchenry.edu/aspnet_client/system_web/1_1_4322/WebUIValidation.js



event.srcElement.Validators

undefined

when I go to IE8. Do you want to access Validators

in DispHTMLAnchorElement

?

0


source


If you have something like this in your datepicker setup:

onSelect: function () {this.focus (); } onClose: function () {this.focus (); }

This makes the element receive focus and is thus validated by the validator plugin.



Unfortunately, in IE7 this throws an error as the focus event gets fired twice and the datepicker gets confused and reappears.

The solution is not to explicitly call the validator on an element and then move focus to the next element for IE to preserve the tab order.

                onSelect: function () {
                    var elementCounter, input, form;
                    input = $(this);
                    form = input.parents('form:first');

                    // validate the selected date
                    form.validate().element(this);

                    if ($.browser.msie && $.browser.version < 8) {
                       // MSIE 7 triggers focus event twice, forcing the datepicker to re-open
                       // to get around this, we move the focus to the next form element

                       for (var elementCounter = 0; elementCounter < form[0].elements.length; elementCounter++){
                           if (form[0].elements[elementCounter].name == input.attr('name')) {
                               $(form[0].elements[elementCounter+1]).focus();
                               break;
                           }
                       }
                    } else {
                       // give focus back to the input element to preserve tabbing
                       $(this).trigger('focus');
                    }
                },
                onClose: function () {

                    // validate the selected date
                    $(this).parents('form:first').validate().element(this);

                }

      

+1


source


If you include the tabindex attribute on your input fields, this might work for you:

onClose: function() {
    $('input[tabindex="' + ($(this).attr('tabindex') + 1) + '"]').focus();
}

      

0


source







All Articles