jquery archive

HRA/SPH

Two-phased project to redesign a site and augment an existing site.
dylan's picture

Revenge of the node comments: a pure jQuery comment pager

A previous post described how to reposition node comments with Drupal's hook_menu_alter(), to facilitate a tabbed interface. One side effect that popped up was pagers – when a pager link was clicked, the tab state got reset. The solution was to refresh the #comments div with AJAX. As an interesting twist, it uses the ability of jQuery's $() to construct a new DOM object from HTML. This means that no new menu callback is needed in Drupal; it fetches the comments directly from the href in the pager link. While a little inefficient, this technique has the cool benefit of being able to grab any content from anywhere on your site, with merely a URL and a selector. It also degrades gracefully for non-javascript users; since without JS the tabs appear as sequential blocks the pager will function normally. (The following code is based on the AJAX Comments project). Read More…

2 comments. Filed under drupal, jquery.

barrett's picture

Drupal/AJAX: Exercise caution when using special foreign characters

I was recently working on a Brazilian Drupal 6.x site that uses CCK forms and needed some functionality to map a dropdown select list of states to another dropdown of cities in the chosen state, which I accomplished using a combination of the drupal_json function, as well as jQuery and AJAX, hooked into the drupal menu system. I learned how to use this functionality quite easily from Pro Drupal Development Chapter 17 - Using jQuery and have implemented it on a number of sites to date. Pro Drupal Development is definitely worth having as a desktop resource. Read More…