I am tring to make a movable sharebox, and i want to memorize the position in wich the user locates the sharebox with localstorage or cookie. But my problem is that after the first drag you cannot drag the box again. And also i cannot use the ui.position().left command. It wont return anything.
html code:
<div id="draggable" class="ui-widget-content">Drag me around</div>
script
function local_storage()
{
var test = 'test';
try
{
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
}
catch(e)
{
return false;
}
}
$( "#draggable" ).draggable({
stop: function(event, ui) {
if (local_storage() === true)
{
var Stoppos = $(this).position();
localStorage.setItem('left', Stoppos.left);
localStorage.setItem('top', Stoppos.top);
//localStorage.setItem('left', ui.position().left);
//localStorage.setItem('top', ui.position().top);
setCookie('sharebox','',-1);
}
else
{
//setCookie('sharebox', top, ui.position().top);
//setCookie('sharebox', left, ui.position().left);
setCookie('sharebox', top, Stoppos.top);
setCookie('sharebox', left, Stoppos.left);
}
}
});
I made a jsfiddle for example: http://jsfiddle.net/maguse/4x8jeo0x/ Can anyone tell me why it stops and how to make it work? Thank you