slugit-jquery
slugit-jquery copied to clipboard
Example with after function
Could I ask for an example with "after" function?
Cannot replace ! char, this char caused error in url of browser.
@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,
@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<===