SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question moving and saving controls postions at runtime......

    hi guys,
    I have to move and save the postions of div at runtime into database.
    so that when user login next time ... it shows the page as it is saved.
    u can see that example in www.iGoogle.com...

    any ideas...
    thnx...
    I was born intelligent,
    But Google ruined me.

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Sydney, Australia
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jquery has various ui plugins for drag/drop.

    A simple plan would be to make the div elements draggable. use the drag complete event to fire an ajax request that would send all the div's top/left offsets. Your server side script would process each div's offsets and store them into the database.

    When you refresh the page, you can attempt to load the saved positions from the database.. if none exist, use your own defaults.

  3. #3
    Born to Code rainadaman's Avatar
    Join Date
    Feb 2005
    Location
    india
    Posts
    793
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thnx,
    I have the coordinates to save into database...
    1 problem is still there.. like u can see that in iGoogle , when we move to some pre-specified area it automatically place div to that area...
    I mean used doesn't have full liberty to put in any place...
    I am talking about the area which shows up in dotted line..
    how to get that.... any idea....


    I think u got my point....
    thnx
    I was born intelligent,
    But Google ruined me.

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Sydney, Australia
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly start by defining the left and right sides of each column as offsets against the document. This way when you drag a div, you can figure out which column is the closest. When the div is released you can move it into the closest column by using the columns offsets and the div's offset.

    You would also need to store the offsets + width/height of all the other drag elements. When dragging you could figure out what is underneath it and move it down the calculated size of the current element.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •