Scriptaculous - Saving a positions co-ordinates?
Just wondering this, but say I had a image in scriptaculous and I dragged it around etc. If I pressed save, meaning it would grab the information for the x and y co-ordinates using "document.getElementById('DIVNAME').style.left;" and "document.getElementById('DIVNAME').style.top;" and sent the information to a database, would the getElementById work?
As in, every time I moved the image would it update the style.top and style.left of the image and send it to the database?
If you don't understand I may be able to explain it more, hopefully. :P
Yes, that would work. The values for 'left' and 'top' won't necessarily be relative to the browser though, so depending on how you're reusing them it could cause problems. If you're going to be setting the values in the same HTML layout it will be fine, but otherwise you might want to use Prototype's getCumulativeOffset instead.
As a tip, if you're using Scriptaculous anyway, then Prototype's $() method is available to you, to save having to type document.getElementById so often.
|All times are GMT +1. The time now is 02:54 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.