Contact Doug!
Learn About Doug!
View Doug Boude's online resume
updated 11/18/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...
Florida web site design



Czech your Page Rank!
Check Page Rank of any web site pages instantly:
This free page rank checking tool is powered by Page Rank Checker service
Surf's Up!
Visit Egosurf.org and massage YOUR web ego!
My Score: 9,001
Doug's Books

Read (and recommend)

  • Men are from Mars, Women are from Venus
  • The Wisdom of Crowds: Why the Many Are Smarter Than the Few and How Collective Wisdom Shapes Business, Economies, Societies and Nations
  • Blink: The Power of Thinking Without Thinking
  • Head First Design Patterns
  • Transact-SQL Programming
  • What's So Amazing About Grace?
  • Just So Stories (Rudyard Kipling collection)

Reading

  • Prayer: Does it Make Any Difference?
  • Data Mining (Practical Machine Learning Tools and Techniques)
<< August, 2006 >>
SMTWTFS
12345
6789101112
13141516171819
20212223242526
2728293031
Search Blog

Recent Comments
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS

Powered by
BlogCFM v1.11

30 March 2009
Changing Scriptaculous' Sortable ID Parser

My scenario:

I'm using Scriptaculous and CF8 to create a "stacked" PDF based on a user's re-ordering of a list of uploaded files (you can check out the live app here). In order to do this simply, I'm making the file name part of the sortable list item's ID value, like so: ID="file~#filename#" . Well, Scriptaculous has a built in way of dealing with sortable item ID values, where it's looking for some text followed by an underscore followed by a numeric value. In order to break away from this assumption, the latest version of Scriptaculous (1.8.2) offers an option called "format" that allows you to specify a regular expression to override the default one.

So, here's my code that creates the unordered list of files:

   <cfdirectory action="list" directory="#uploadedfiles#" name="qryFiles" />
   <div id="filelist">
    <ul id="filestack">
     <cfoutput query="qryFiles">
      <li id="file~#name#" class="fileitem" ext="#listlast(name,".")#">#name#</li>
     </cfoutput>
    </ul>
   </div>

and here's the JS I use to turn this list into a sortable:

Sortable.create('filestack',{format:/^file~(.*)$/});

Executing the following JS will show you that the regex is correct:

alert(Sortable.sequence('filestack'));

Not hard stuff, but it took me a while to piece it all together so I thought I'd share in case it saves someone else a little time.




Posted by dougboude at 11:30 AM | PRINT THIS POST! |Link | 0 comments
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

No comments found.

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

9 plus 18 equals
Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!