ajax1Add my vote for this tag extract_doc1Add my vote for this tag create new tag
, view all tags

Using AJAX and Script.aculo.us to dynamically populate the topic Jump box.

Scriptaculous.js is a useful adjunct to prototype.js which offers several extensions which can be used in our wiki. Recently, we used their Autocompleter coupled with a small back-end script to dynamically populate the Topic Jump box.

When the User types into the Jump box, they are prompted with a ordered list of all topics starting with those characters.

This was accomplished by adding some <script> inclusions, some css, a div and a javascript initialization call, to the topic which defines the Jump box. (to be filled in)

A small back-end script processes the request and returns an XML response.

Once I get to work I will post the code, and more complete documentation.

-- Contributors: CraigMeyer - 25 Jan 2007


We had very bad experience with the prototype scripts.

Certain versions of IE (including the one we used where I work) crash the minute you load it.

-- KennethLavrsen - 25 Jan 2007

TWikiAjaxContrib offers AJAX functionality based on Yahoo's User Interface library (also made available for TWiki with YahooUserInterfaceContrib). I would like to see autocomplete functionality using these contribs.

-- ArthurClemens - 25 Jan 2007

Craig, I have often wondered if it was possible to implement that functionality for the Topic Jump box. After jumping to enough topics you get a similar result with the browser remembering the ones you've jumped to and narrowing it down for you as you type, but an AJAX solution sounds great.

-- JoshuaJohnston - 25 Jan 2007

An ajax-based topic selector would be also of use to reparent topics. Oopsmore is so slow as it fetches the complete topiclist, as you might occasionally reparent the topic. This i.e. downs your server on large webs.

Apropos large webs. How does the current ajax solution perform on large webs (10k topics or more)?

-- MichaelDaum - 25 Jan 2007

Note that autocomplete asks from the user that he knows the possible items. Good for Jump, not so good for assigning a parent.

-- ArthurClemens - 25 Jan 2007

Ken - I certainly agree that getting cross-browser stuff to work is a pain! That's why we are using the latest prototype.js V1.5. Also, we have the advantage of having a corporate mandated version of the browser; V6.0 Internet Explorer, though developers use Firefox wink .

I really wanted to use the Autocompleter implemented at Beauscott.com as it uses the select dropdown, rather than a div to display the alternatives, which is standard and allows for simple scrolling. I had troubles getting it to work on IE, though the demo works fine! Programmer error, I guess wink

Arthur - I wasn't aware of Yahoo versions of autocomplete, they can certainly be evaluated Yahoo's autocomplete, the documentation looks a bit daunting.

Michael - We don't have webs that big, max is about 1500 topics. We use a heirarchical web structure. The server script could be extended to cache the directory listing in a sorted file, updated as new topics are noticed. Also one can limit how many results are returned.

I put all the needed css, and javascript into the WebLeftBarSearch page (which I attached to this topic).

Here are just the changes, for illustration.

<div class="patternFormHolder">

<script src="/js/scriptaculous.js" type="text/javascript"></script>

<style type='text/css'>
 div.autocomplete {
      border:1px solid #888;
    div.autocomplete ul {
    div.autocomplete ul li.selected { background-color: #ffb;}
    div.autocomplete ul li {
<input type="text" class="patternFormField patternFormFieldDefaultColor" name="topic" id="auto_topic" size="24" value="Jump" onfocus="clearDefaultandCSS(this);" /><div id="suggestionBox" class="autocomplete"></div>
<script type="text/javascript" language="javascript">
  var myAutoCompleter = new Ajax.Autocompleter('auto_topic', 'suggestionBox', '%SCRIPTURLPATH{SuggestTopic}%/%BASEWEB%', {frequency: 0.25});

The changes are:

  • Include the needed javascript (we already have prototype.js included in the head)
  • Setup the (default) css
  • put the <div id="suggestionBox" right after the input field
  • call the initialization javascript.

-- CraigMeyer - 25 Jan 2007

Michael - I extended the server script to cache the Topic names in sorted order, which could improve performance on huge webs. I haven't done any timing yet, I need to find a huge directory for the test. I am curious which will be faster? After all reading a directory (in the PERL kernel) and doing a regexp in PERL, then a sort on the hits could be faster than reading a file (in PERL) plus the regexp? When you say 10K topics, there are actually at least 20K files (.txt and .txt,v) so caching could be a big improvement. I will test tomorrow, and post the results and the code.

-- CraigMeyer - 26 Jan 2007

Michael - Wow, you were correct! Caching makes it 20 times faster on large directories! I am attaching the caching version (uses cache file %WEB%/.TopicList)

-- CraigMeyer - 26 Jan 2007

We actually also use IE 6.0 and this is what crashes with the prototype.js. And when I say crash I mean crash. It crashes IE on the load so you cannot view topics in TWiki at all. And it is not all the machines that does it. Approx 1 of 2. Never found out whet caused it. First we downgraded the prototype to an older version which fixed it. And later Arthur replaced it with something better.

I was only meaning to warn against this odd problem in case you did not know.

-- KennethLavrsen - 26 Jan 2007

TopicClassification TWikiAddOnProduct
TopicSummary Using AJAX and Script.aculo.us to dynamically populate the Topic Jump Box


Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatEXT SuggestTopic r1 manage 2.0 K 2007-01-25 - 21:18 CraigMeyer The AJAX server script
Unknown file formatEXT TopicCache r1 manage 3.3 K 2007-01-26 - 22:09 CraigMeyer Caching version of SuggestTopic
Texttxt WebLeftBarSearch.txt r1 manage 2.6 K 2007-01-25 - 21:09 CraigMeyer The improved WebLeftBarSearch topic
JavaScriptjs prototype.js r1 manage 63.3 K 2007-01-25 - 21:24 CraigMeyer prototype.js V1.5
JavaScriptjs scriptaculous.js r1 manage 2.3 K 2007-01-25 - 21:10 CraigMeyer The Script.aculo.us code
Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2007-01-26 - KennethLavrsen
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.