I love how easy ActiveAdmin is to use out of the box, but it can force you into using a panoply of workarounds for forms with any significant level of complexity. The challenge I faced was making this:
Sometimes we would like to find out which particular element (or set of elements) has user clicked on. However, binding click events on each element manually might not be the most practical way of accomplishing this. Or we might want to fire a certain event if user clicks on anything but particular element(s). I will describe one of such scenarios below and offer one of possible solutions to it using jQuery.
This span is too big for this div
This is a simple problem and a simple solution. Often in the world of dynamic data we find ourselves with data that is larger than the container. There are ways of handling this like a scrolling div or adding ellipses to chopped of text, but what if you absolutely must see all of the text and are willing to change to font size to accomplish this? Using this little recursive jQuery snippet you can accomplish this.
The latest version of the jQuery Lazy Load plugin (released Jan 29th, 2012) included the ability to customize your data attribute parameter. This is a pretty helpful update; I realized it could be used to set multiple source images for the same node. Here's how you can use it to optimize images, cutting down on data transfer for mobile devices.
There's a lot of buzz from developers about HTML5, but what does it really mean to business? I look at in terms of...
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
(The following code is based on the AJAX Comments project).
During the theming process for the Emmys, specifically Emmys.com and Emmys.tv, we were presented with 2 differently styled marquees. On Emmys.com, the pager uses an image, while on Emmys.tv, the pager uses number with a background image along with next/previous buttons.
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.