0

I am attempting to perform some action on the foucsin of the textbox. However, for some reason the event never fires.

$(".ddlAddListinTo li").click(function () {
    var urlstring = "../ActionTypes";
    $.post(urlstring, function (data) {
        $(window.open(urlstring, 'Contacts', 'width=750, height=400')).load(function (e) {

      //  Here "this" will be the pop up window. 
             $(this.document).find('#txtAutocompleteContact').on({
                   'focusin': function (event) {
                   alert('You are inside the Contact text box of the Contacts Popup');
                         }
                    });
               });
         });
});
BumbleBee
  • 10,429
  • 20
  • 78
  • 123

1 Answers1

1

When doing it that way, you generally have to find the body or use contents() to access the contents, as in

$(this.document).contents().find('#txtAutocompleteContact')

but in this case using a little plain javascript seems more appropriate :

$(".ddlAddListinTo li").on('click', function () {
    var urlstring = "../ActionTypes";
    $.post(urlstring, function (data) {
        var wind = window.open(urlstring, 'Contacts', 'width=750, height=400');

        wind.onload = function() {
             var elem = this.document.getElementById('txtAutocompleteContact');

              $(elem).on('focus', function() {
                  alert('You are inside the Contact text box of the Contacts Popup');
              });
         }
    });
});
adeneo
  • 312,895
  • 29
  • 395
  • 388