Rey Libutan
Rey Libutan

Reputation: 5314

IE focus when div is scrolled

My goal is to simulate the behavior of jquery "datepicker" but instead of showing a calendar, I want to show a selectable table.

I have a working fiddle in chrome and FF but not in IE8 :( (I don't know if you guys can run fiddles with IE but if you can't, please make a local copy and open with IE, thanks)

Problems:

  1. in IE, when I scroll, the div is hidden so I fixed it with

            $("#test_table_container").scroll(function() {
                if (myTimeOut) {
                    clearTimeout(myTimeOut);
                }
            });
    

    but when I click on the scrollbar (instead of dragging it), the div is hidden. This is also the same when click the arrow buttons. This does not happen though if I drag the scroll bar FIRST, THEN click on the scroll bar.

  2. the timout duration (90ms) is unfortunately very intermittent, sometimes I am able to select values in tr and then the div is hidden, but sometimes the div is hidden FIRST, before the click event of tr is triggered that's why the value is not reflected in the input.

Upvotes: 0

Views: 108

Answers (1)

Abhitalks
Abhitalks

Reputation: 28387

There should be no need for a setTimeout hack for this. You may be better off, by binding a click on the body and then use delegation.

Please see the updated fiddle: http://jsfiddle.net/dz9VC/1/

This is just a crude code, but you will get the idea and can then optimize it as per your need. The updated fiddle should work on IE as well. The reason it wasn't working in IE8 specifically, maybe due to the box-model differences.

Upvotes: 1

Related Questions