views:

36

answers:

1

Hello all,

I'm doing a drag and drop module now, and I need to get the position of the element on screen (don't really care if it is page, screen or offset or any thing else), but it has to be from the right as my project is in a RTL language....everything is RTL, so the data has to be saved like that to the DB because resolution and resizing matters...

Does anyone know a jQuery/Javascript/workaround for getting position from the right? I couldn't find anything about it.

+1  A: 

Since you're asking about jQuery, I'm assuming you're talking about the position() method, and that would be relative to the parent object, right? The position from the right would therefore be:

var pfr = element.parent().width() - element.position().left;
Elf Sternberg
Elf, 10x, It's still not working for me, getting all the time the same number, like it is not calculating the drop, i don't know...when u say Element, do u mean $(this) or UI.dragabble ???
Erez
@Erez - What is this "10x"? If you're referring to "thank you"s. I believe they are handed out in bundles of millions: "thanks a million" ;)
Peter Ajtai
LOL....Yes, 10x is thank you and i have no problems saying 'thanks a million', my problems are with jquery..lol :-) how come there is no position for the right???? :-)
Erez
@Erez - Depends where you use it. If it's with drag, then it's `$(this)`, since `this` is referring to the `element` of interest. Take a look here ==> http://jsfiddle.net/9ytFF/
Peter Ajtai
Thanks a million ;-) it's working, no parent() thow, just: ($(window).width() - ui.position.left), that giving the the resoult i was looking for...:-)
Erez