user2585299
user2585299

Reputation: 883

Scroll event not getting fired for a div

I am using jQuery dialog widget. The html rendered for that dialog is shown below in the jsFiddle. Scroll bars can be seen in the outer div but the scroll event is not firing.

http://jsfiddle.net/dM5kY/

Adding below javascript does not fire the event:

$("#dialog).scroll(function(){
 alert("scroll");
});

$("#dialog").on('scroll',function(){
   alert("scroll 1");
});

Upvotes: 0

Views: 1504

Answers (3)

byJeevan
byJeevan

Reputation: 3838

Check my update here:

http://jsfiddle.net/JeekOnline/dM5kY/21/

$( document ).ready(function() {
 $("#dialog").scroll(function(){
    alert("scroll");
 });
});

Upvotes: 1

pumpkinzzz
pumpkinzzz

Reputation: 2967

There are several error:

  1. missing jQuery library
  2. dialog height should be less then modal height otherwise scroll wont appear
  3. set CSS property overflow: scroll

demo here: http://jsfiddle.net/dM5kY/19/

$( document ).ready(function() {
    $("#dialog").on('scroll', function(){
        alert("scroll 1");
    });
});

Upvotes: 2

raviture
raviture

Reputation: 1059

You did not added jquery library. here is the updated jquery code:

$(function(){
    $('#dialog').scroll(function(){
      alert("scroll");
    });
})

Updated fiddle http://jsfiddle.net/dM5kY/18/

Upvotes: 2

Related Questions