Disable autocomplete for keyup on jQuery

There’s an event I cannot handle on jQuery: the Firefox autocomplete on textarea.

If you have to use the keyup event for a string match on textarea content, you have to exclude autocompletion, that is out of keyup logic.

To do this, simply add:

$(‘#myelement’).attr(‘autocomplete’, ‘off’);

to your jQuery. Autocomplete will be disabled and the unhandled event will not fire.

See also:

Character substitution on Jquery

Here an easy way to search and replace each occurrence a group of characters (in this case underscore and minus) with another (in this case a space) on a specified element (in this case each A), using Jquery javascript library.

$("a").each(function() {
   $(this).html($(this).html().replace(/[_-]/g," "));

The first argument passed on replace is a regex, if you just pass a single character (like “_” or “-“) only first occurrence for each element.

Real world usage: I use this onto a long page, where a table has long filenames with underscore and minus in place of spaces. This trick allows in my case to show tables nicely, without caring on a mass substitution via server side scripting.

See also:

Display HTML on Lightbox v2

I’m trying drupal 6.x from some weeks ago. On Drupal 5.x, I’ve used Greybox Redux module to display HTML content on a Javascript popup window. On 6.x, where Greybox isn’t available, I try successfully Lightbox v2. I use this module for images on many sites: syntax to display HTML on a popup IFRAME changes slightly:

<a rel="lightframe" href="http://example.com" title="Lightframe label">Link Text</a>

And this is the l() equivalent:

l('Link text', 'http://example.com', array('attributes' => array('rel'=>'lightframe', 'title'=>'"Lightframe label')))

You can also use the grouping feature to browse prev/next elements:


customize display style:

'rel'=>'lightframe[|width: 800px; height: 600px;]'


'rel'=>'lightframe[mygroup|width: 800px; height: 600px;]'

Complete example:

l('Link text', 'http://example.com', array('attributes' => array('rel'=>'lightframe[mygroup|width: 800px; height: 600px;]', 'title'=>'"Lightframe label')))

See also:

i can patch this!

*nix command of the day:

diff -Naur old new > new.patch

Where “old” and “new” are files or directories to patch.

Example (a Drupal patch for IDs duplication):

$ patch -p0<fapi-5.x-dupe-id_111719-151.patch
patching file includes/form.inc

Creating patch for Drupal:
diff -up original.php new.php > filename.patch

another example:

diff -up path/to/file/example.module path/to/file/exampleNew.module > mypatchname.patch

See also: