/    Sign up×
Community /Pin to ProfileBookmark

Sortables with jquery and cookies?

I have a sortable div page [URL=”http://bt5.awardspace.com”]http://bt5.awardspace.com[/URL] and the sortable works just fine.. My issue is i need to set a cookie after they sort it so that the next time they come to the page the order is kept.. any ideas??

[URL=”http://bt5.awardspace.com”]index.html [/URL]

[URL=”http://bt5.awardspace.com/jquery-1.2.6.min.js”]jquery-1.2.6.min.js[/URL]

[URL=”http://bt5.awardspace.com/interface.js”]interface.js[/URL]

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@webdevisedauthorSep 10.2008 — Bu Bump Bump
Copy linkTweet thisAlerts:
@webdevisedauthorSep 10.2008 — Bu Bump Bump 2
Copy linkTweet thisAlerts:
@konithomimoSep 15.2008 — instead of using a cookie use a server-side session.
Copy linkTweet thisAlerts:
@webdevisedauthorSep 15.2008 — I am using a framework called Django no server side scripts can be run cause it uses a template system..

But what about this.. I know that asp can write js and js can run an extrenal asp file into a page. Any thoughts on that?

AND..

I have found this code that randomly reorders each page load.. wonder how i can use this script..

[code=html]
<style type="text/css">

.jsclass body .randomordercontent{
display: none;
}

</style>

<script type="text/javascript">

if (document.getElementById)
document.documentElement.className = 'jsclass'; //hide content for DOM capable browsers


var randomordercontentdisplay={
divholders:new Object(),
masterclass: "randomordercontent",

init:function(){
if (!document.getElementById)
return
var alldivs=document.getElementsByTagName("div")
var randomcontentsearch=new RegExp(this.masterclass+"\s+(group\d+)", "i") //check for CSS class="randomcontent groupX" (x=integer)
for (var i=0; i<alldivs.length; i++){
if (randomcontentsearch.test(alldivs[i].className)){
if (typeof this.divholders[RegExp.$1]=="undefined"){ //if object to hold this group of divs doesn't exist yet
this.divholders[RegExp.$1]=new Object() //create object
this.divholders[RegExp.$1].ref=[] //create array to hold each div within group
this.divholders[RegExp.$1].contents=[] //create array to hold each div's content within group
}
this.divholders[RegExp.$1].ref.push(alldivs[i]) //add this div to the array
this.divholders[RegExp.$1].contents.push(alldivs[i].innerHTML) //add this div's content to the array
}
}
this.scrambleorder()
},

scrambleorder:function(){
for (group in this.divholders){ //loop thru each array within object
this.divholders[group].contents.sort(function() {return 0.5 - Math.random()}) //scramble contents array
for (var i=0; i<this.divholders[group].ref.length; i++){
this.divholders[group].ref[i].innerHTML=this.divholders[group].contents[i]
this.divholders[group].ref[i].style.display="block"
}
}
}
}

</script>
<head>
<h3>Random Order Content Group 1 (4 pieces of content total):</h3>

<div class="randomordercontent group1">

<p style="border:1px dashed gray; background-color:lightyellow; padding: 10px">Group 1 Content 1</p>

</div>

<div class="randomordercontent group1">

<p style="border:1px dashed gray; background-color:lightyellow; padding: 10px">Group 1 Content 2</p>

</div>

<div class="randomordercontent group1">

<p style="border:1px dashed gray; background-color:lightyellow; padding: 10px">Group 1 Content 3</p>

</div>

<div class="randomordercontent group1">

<p style="border:1px dashed gray; background-color:lightyellow; padding: 10px">Group 1 Content 4</p>

</div>




<h3>Random Order Content Group 2 (2 pieces of content total):</h3>

<div class="randomordercontent group2">

<p style="border:1px dashed gray; background-color:#D8EA99; padding: 10px">Group 2 Content 1</p>

</div>

<div class="randomordercontent group2">

<p style="border:1px dashed gray; background-color:#D8EA99; padding: 10px">Group 2 Content 2</p>

</div>

<script type="text/javascript">

randomordercontentdisplay.init()

</script>[/code]
Copy linkTweet thisAlerts:
@webdevisedauthorSep 22.2008 — Nobody has any ideas???
Copy linkTweet thisAlerts:
@sushiSep 22.2008 — I'll get you started.

-Bind a new function to every link that tablesorter creates (at the top of each TH)

-with that function save each sort that is performed in a global variable, appending each new sort using any algorithm that you prefer.

-save that global variable as a cookie

as for reading

-check if that cookie is present

-decrypt it (depending on what algorithm you used to track the sorts)

-bind an init function to your script (so after it tablesorts, it runs your function and sorts like the way it was before)

have fun.
Copy linkTweet thisAlerts:
@webdevisedauthorSep 23.2008 — I will try it and let you know what i have...
×

Success!

Help @webdevised spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...