5

I have developed a web application in asp.net 3.5. It is consuming lot of javascript/JQuery events and working properly in normal browser in pc, but my client is saying that these are not working in tablet-pc/android and IPad . Like I have a dropdownlist in which I am firing keypress and mouse click events in javascript, and these are perfectly working in normal browsers, I need to be in working form all these in IPads and android tablet-pcs.

Crab Bucket
  • 6,219
  • 8
  • 38
  • 73
Bilal lilla
  • 618
  • 3
  • 8
  • 29
  • well you do not get everything for free (effortless), consider that on iPads and Android devices the concept of click and double click is different than on a PC. While jQuery is a very good choice to support cross-browser client side programming, it then depends on how you use it. Check this one for details: http://stackoverflow.com/questions/475674/what-javascript-events-are-available-to-webkit-on-android – Davide Piras Jan 20 '12 at 09:26
  • I think this link is for targeting only the android users, but my target is both the normal windows pc browser ,tablet and IPad . – Bilal lilla Jan 20 '12 at 10:15

3 Answers3

4

The click events won't work on the iPad as it is touch screen - click vs touch I guess. Have you considered using JQueryMobile rather than JQuery? I is optimised for touch devices - as it states on the very front page of the site.

Rather than using click it has a whole host of events you can hook into i.e. tap, swipe, taphold etc... It would be easy enough to hook the same function into a click and a tap event i.e.

('myelement').bind('click', function(event){
   myClickFunction();   
});

('myelement').bind('tap', function(event){
   myClickFunction();   
});

There are possibly (almost certainly) more elegant ways to do this - but that's just a start really.

Crab Bucket
  • 6,219
  • 8
  • 38
  • 73
  • 4
    You could do this: `$('myelement').bind('click', myClickFunction ).bind('tap', myClickFunction );` to make the code look pretty – Andrew Jackman Jan 20 '12 at 11:34
  • I added a new dropdownlist there and fired the normal event of the selectedIndexCHanged there and it works. Because in touch screens we do not need to fire any event of left arrow or down arrow or something else. So far I am waiting for my client .I hope it will work on his machine as well ,because it worked on my mcahine. – Bilal lilla Jan 23 '12 at 15:38
1

There are touch events for a touch screen device:

touchstart: a finger is placed on a DOM element.
touchmove: a finger is dragged along a DOM element.
touchend: a finger is removed from a DOM element.

Maybe you want to try working with those. That being said, it is good to use events like change (or onchange inline with the element) for a drop down list because it is will work no matter what changes it (keyboard, mouse event or touch event).

Here is a resource to learn more.

Andrew Jackman
  • 13,781
  • 7
  • 35
  • 44
0

You can use a combination and try touchstart instead of tap

('myelement').bind('touchstart click', function(event){
   myClickFunction();   
});
Jacksnap13
  • 127
  • 9