arielsalminen / TinyNav.js

Responsive navigation plugin that weighs just 443 bytes
http://tinynav.viljamis.com/
635 stars 207 forks source link

Enhancement: string replace option #77

Open boye opened 9 years ago

boye commented 9 years ago

First and foremost, thanks for sharing TinyNav.js with the GitHub community, it's a great plugin!

Since I needed something to format the textNode of the <option> elements I extended tinyNav.js with a replace option. It works as follows:

$('.nav-filter').tinyNav({
    active: 'selected',
    replace: {
        regex: /\d{1,3}/,
        fn: function (nr) {
            return '(' + nr + ')';
        }
    }
});

Basically it's a simple way to modify the content before it's gets injected in the DOM. If you want to...I could do a pull request. Just let me know.

Cheers