Skip to main content

Bug Tracker

Side navigation

#4361 closed enhancement (fixed)

Opened March 17, 2009 12:02AM UTC

Closed November 19, 2010 02:11AM UTC

replaceWith() accept callback for content

Reported by: jablko Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

I wish that the replaceWith() function accepted for its "content" argument - in addition to a string, or an element, or a jQuery - a callback which would return one of the three existing types of argument.

My application is I am trying to autolink strings like "r1234" to our project's repository browser. I don't want to autolink strings in <textarea> elements:

$(document).ready(function ()
  {
    $(':not(textarea)').contents()
      .filter(function ()
        {
          return 3 == this.nodeType;
        })
      .replace(function ()
        {
          this.nodeValue
            .replace(/\\br(\\d+)\\b/g, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/source/detail?r=$1">$&</a>')
            .replace(/\\brevision\\s*#?\\s*(\\d+)\\b/gi, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/source/detail?r=$1">$&</a>')
            .replace(/\\bissue\\s*#?\\s*(\\d+)\\b/gi, '<a class="external text" href="http://code.google.com/p/qubit-toolkit/issues/detail?id=$1">$&</a>'));
        });
  });
Attachments (0)
Change History (2)

Changed October 14, 2009 03:29AM UTC by dmethvin comment:1

component: unfilledcore

It's easy to write a small plugin to do this, so it's not really appropriate for jQuery core.

Changed November 19, 2010 02:11AM UTC by dmethvin comment:2

resolution: → fixed
status: newclosed

Implemented...