GithubHelp home page GithubHelp logo

string.slugify.js's Introduction

String.Slugify

Extends the String native object to have a slugify method, useful for url slugs.

Screenshot

How to Use

String.Slugify extends the native String object, so it works on any ordinary string.

"slugify  ME    n%ø#w".slugify()

Returns "slugify-me-now"

Real world usage example

This example shows how you can use slugify on two text inputs to create valid slugs from an ordinary title field.

The title field <input id="title">, and the slug <input id="alias">.

We're listening to the change event on the slug input, and the keyup and keydown events additionally on the <input id="title"> element; This is to make the <input id="alias"> input update as you type the title and be slugified in the process:

	var aliasvalidator = function(){
		this.value = this.value.slugify();
	};
	var titlevalidator = function(){
		if(!$('alias').defaultValue) $('alias').value = this.value.slugify();
	};
	
	$('title').addEvents({'keyup': titlevalidator, 'keydown': titlevalidator, 'change': titlevalidator});
	$('alias').addEvents({'change': aliasvalidator});

Screenshots

Screenshot Screenshot

string.slugify.js's People

Contributors

stipsan avatar cbeloch avatar appinteractive avatar

Stargazers

Mustafa Akçakaya avatar Tiago Braga avatar Epety avatar Paul Schwarz avatar  avatar Tua Nguyen avatar Joshua Byrd avatar  avatar Jake Jarvis avatar Sandor Tokodi avatar  avatar Ryo Inoue avatar Wesley Gervais avatar David Yeiser avatar Mark Simpson avatar  avatar Simon Leblanc avatar Rick Blalock avatar  avatar Arian Stolwijk avatar  avatar Rafael Santos Sá avatar Majic3 avatar Honza Černý avatar Bruno Heridet avatar  avatar Jay Williams avatar

Watchers

 avatar James Cloos avatar  avatar

string.slugify.js's Issues

No license

Can you add a license please as it seems your intent is to share this code? I can't use this without a license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.