jQuery draggable, save the position after reloaded page? -
i did ton of research need more personalized answer, pretty positive saving draggable values requires cookies solution, unlike jquery .slider can save values this
//jquery ui slider jquery( ".slider" ).slider({ animate: true, range: "min", value: $("input.slider-value").val(), min: 50, max: 700, step: 1, //this gets live reading of value , prints on page slide: function( event, ui ) { jquery( "#slider-result" ).html( ui.value ); jquery( ".static_preview_image" ).height( ui.value ); }, //this updates hidden form field can submit data using form change: function(event, ui) { jquery('#hidden').attr('value', ui.value); } }); $( ".static_preview_image" ).css({height: $("input.slider-value").val()}); //this gives element height of slider, stored in slider function...
from research .draggable not work in same fashion, requires cookies?
if thats true, can explain how use cookies in clean way possible, want save top, right, left, bottom values...
here draggable function
$( ".myelemnt" ).draggable({ containment: '#_moon_static_bg_status', // set containment // read in post, outputs live value of .myelemnt start of drag. start: function(event, ui) { // show start dragged position of image. var startpos = $(this).position(); $("div#start").text("start: \nleft: "+ startpos.left + "\ntop: " + startpos.top); }, // same above prints current position myelemnt stops stop: function(event, ui) { // show dropped position. var stoppos = $(this).position(); $("div#stop").text("stop: \nleft: "+ stoppos.left + "\ntop: " + stoppos.top); } });
i want simple writing similar how value of slider
$( ".static_preview_image" ).css({height: $("input.slider-value").val()});
but think need use of cookies...
two methods: first, cookies work persist between page refreshes. second, if using php can use clients session data server side remember it, method requires send data (through ajax or similar) client after move item server notify of new position can remember it.
edit: comment above using localstorage sounds excellent method, try first.
Comments
Post a Comment