slugit-jquery icon indicating copy to clipboard operation
slugit-jquery copied to clipboard

Example with after function

Open jezozwierzak opened this issue 11 years ago • 3 comments

Could I ask for an example with "after" function?

jezozwierzak avatar Sep 26 '13 08:09 jezozwierzak

Cannot replace ! char, this char caused error in url of browser.

mrpeo avatar Sep 17 '14 09:09 mrpeo

@mrpeo Your problem can be resolved by adding the before method callback, like so:

before: function(text) {
    return text
        .split("'").join('')
        .split('!').join('')
        .split('(').join('')
        .split(')').join('');
}

This is a temporary fix until the author fixes the issues. Although it's been over 2 years since the last commit so I'm doubtful of that,

DavidTheSimon avatar Aug 05 '15 13:08 DavidTheSimon

@mrpeo That problem can be resolved by mapping the problematic character to the separator character like this:

map: { '!': '-' }

That way the character will simply act as a separator and the plugin will flow normally without the needing of any callback.

If you map any character to an empty string then the mapping will have no effect at all, because the line 49: if ( chars[text.charAt(i)] ) ===>falsy value<===

kuntur-studio avatar Jul 20 '17 09:07 kuntur-studio