0

I have a question: How can I save my div's position (I have 3 div (with class: my_box_position)) to the cache and restore again using Mootools: My code:

Element.implement({
serializePos: function(){
        var coors = this.getCoordinates();
        return {                
                id: this.id.replace('rb_',''), 
                lefty: coors.top.toInt(),
                leftx: coors.left.toInt(),
                righty: coors.height.toInt() + coors.top.toInt(),
                rightx: coors.width.toInt() + coors.left.toInt(),
                minimized: this.hasClass('rb_minimized')
            }.toSource();
        }
})

Used like this:

var obj = $$('.my_box_position').serializePos();
Cookie.write('box_position',obj);

Now we read from cookie:

if (typeOf(Cookie.read('box_position')) != 'null') {    
                var boxes = eval(Cookie.read('box_position'));
                ...??? How can I set my div position here? 
            }

Thanks.

XTRUST.ORG
  • 3,280
  • 4
  • 34
  • 60

1 Answers1

1

Use setStyles to set height, width and left and top position (using a correct position such as absolute or relative, depending on your case).

lorenzo-s
  • 16,603
  • 15
  • 54
  • 86