Bug Tracker

Opened 11 years ago

Closed 9 years ago

#4361 closed enhancement (fixed)

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>'));
        });
  });

Change History (2)

comment:1 Changed 10 years ago by dmethvin

Component: unfilledcore

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

comment:2 Changed 9 years ago by dmethvin

Resolution: fixed
Status: newclosed

Implemented...

Note: See TracTickets for help on using tickets.