Shuang Liu
Posts: 0
Joined: Wed Jun 26, 2013 2:31 pm

is there a callback in builder to get touch position?

is there a callback in builder to get touch position rather than adding some codes in the source?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

is there a callback in builder to get touch position?

Hi Shuang,

You can read about available events here: http://api.jquerymobile.com/category/...

Most often, the click/touch coordinates are inside the event object that is passed as an event handler argument.

Ivan6481911
Posts: 0
Joined: Tue Dec 10, 2013 11:25 am

is there a callback in builder to get touch position?

Hello!
Can you tell, how to retrieve those x,y coords? I could not find out it with docs above...
Thanks!

Ivan6481911
Posts: 0
Joined: Tue Dec 10, 2013 11:25 am

is there a callback in builder to get touch position?

Great, it works!
But... My alert appears on other screens also. It seems, I have to disable that callback, right?
And another question - how can I assign tap handler to specific element (image)? I tried like this, but did not work:

$( "#lblTourID" ).bind( "tap", function tapHandler(event){
alert('x : ' + event.pageX + ' , y : ' + event.pageY);
});

lblTourID - is Name of element, assigned in UI builder

This code works, but on next screens also:

$( document ).bind( "tap", function tapHandler(event){
alert('x : ' + event.pageX + '\ny : ' + event.pageY);
});

Ivan6481911
Posts: 0
Joined: Tue Dec 10, 2013 11:25 am

is there a callback in builder to get touch position?

Oh-h-h...... I ' ve just found out that I can call JS on Tap event on image (and outer elements) in UI builder. How can I get tap coordinates? There is no parameter, like in handler function.

Ivan6481911
Posts: 0
Joined: Tue Dec 10, 2013 11:25 am

is there a callback in builder to get touch position?

:) A-m-m.... I have found the solution for getting the location of an image click.
here is the code:

$('[dsid="Image1"]').bind('tap', function(e){
var x = e.pageX;
var y = e.pageY;

alert([x, y]);
})

Please, let me know, if this is good solution.
Thank you very much for your help and sorry for bothering...

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

is there a callback in builder to get touch position?

There is easier way.
Add Run JavaScript action on Tap event on image component. Use this js code
precodevar e = arguments[0];
var x = e.pageX;
var y = e.pageY;
alert([x, y]);
/code/pre

Ivan6481911
Posts: 0
Joined: Tue Dec 10, 2013 11:25 am

is there a callback in builder to get touch position?

:) WOW, cool !
Thank you, Oleg!

Ivan6481911
Posts: 0
Joined: Tue Dec 10, 2013 11:25 am

is there a callback in builder to get touch position?

How can I get relative position in Tap event?

Code: Select all

I use this code on Load Event and it works: 

// SET TOUCH EVENT (relatively to parent, not on screen)

$('[dsid="iii"]').bind('tap', function(e){

var posX = $(this).position().left,
posY = $(this).position().top;
alert((e.pageX - posX) + ' , ' + (e.pageY - posY));

})

But on Tap Event I got Nan. I think "this" is not correct object.
When I change this to document I got exception:
Uncaught TypeError: Cannot read property 'top' of undefined

var posX = $(document).position().left,
posY = $(document).position().top;

Return to “Issues”