2

I'm using Air Client with HTML, CSS and Javascript. Trying to scroll the option list using up and down arrow keys. But it seems scrollbar is not scrolling to the top or bottom of the list using up or down key events.I tried following javascript from an Old Post

var SubTypeOptionCount = $("select[name='sub_type']").find("option").length -1;                 

$("select[name='type']")
    .scrollTop($("select[name='type']"\).find("option[value=68]").offset().top);

$("select[name='sub_type']")
    .scrollTop($("select[name='sub_type']").find("option[value=" + SubTypeOptionCount + "]").offset().top);

While testing with chrome or FF. I got an error offset is undefined function.

Please find image attached for details

Screen Grab

Let me know, what I am missing.

EDIT: Added JsFiddle on request.(http://jsfiddle.net/3av7T/2/)

Community
  • 1
  • 1
  • I'm not sure if this has anything to do with AIR. The [air] tag refers to Adobe AIR, a runtime scripted in ActionScript, not JavaScript. – T. Richter Jun 26 '14 at 12:23
  • @T.Richter :Thanks for reply. I'm using **Adobe Air** Only. It supports javascript and jQuery too. –  Jun 26 '14 at 13:21
  • The browser in AIR is old so some JS may not work, there is an event named uncaughtScriptException(HTML component) where you can catch JS errors , what I do is to make an AIR_Browser application, that is a simple webbrowser that I can navigate pages and do tests, also the app contains inputs so I can add JS code and evaluate it. So first make a html page test your code in FF or Chrome then test in this AIR browser – simion314 Jun 26 '14 at 13:42
  • @simion314: As chrome and FF already supports the thing I want there. However by putting some alerts and logs, I had concluded that js is working. But seems to be above code isn't working :( –  Jun 26 '14 at 14:25
  • Please provide your html so I can write up the example in JSFiddle. – Justin Russo Jul 07 '14 at 14:43
  • @JustinRusso :Added HTML in JSFiddle. [http://jsfiddle.net/3av7T/2/] –  Jul 08 '14 at 05:15
  • When I run this in jsfiddle using the javascript code you provided above, I get no errors and the dropdown scrolls. Can you tell me what browser you are using? – Justin Russo Jul 08 '14 at 05:50
  • @JustinRusso: I had seen that error for offset in `Chrome [Version 35.0.1916.153]`. But issue is there in Adobe Air client, It stops working. –  Jul 08 '14 at 06:27
  • Well, the problem is not in Chrome that I can see. The problem is probably specific to Adobe Air Client for sure. There's not much I can help with that. Sometimes I can debug a problem in one browser that will fix all. – Justin Russo Jul 08 '14 at 06:48
  • @JustinRusso: Thanks for reply. But I wonder if you know some javascript code that allows a ` –  Jul 08 '14 at 06:59

1 Answers1

1

Air Client would be having some issues with offset. I had same issue with AIR. Just try out:

$('select').scrollTop(30);

Ignore size of the select from a post :

Community
  • 1
  • 1
Laxmikant Ratnaparkhi
  • 4,745
  • 5
  • 33
  • 49