.on Jquery Function

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

.on Jquery Function

Post by gautamz07 »

Checkout this Jquery pluggin :

https://github.com/luis-almeida/unveil/ ... .unveil.js

Code: Select all

$w.on("scroll.unveil resize.unveil lookup.unveil", unveil);
if i minify the above line to say this :

Code: Select all

$w.on("scroll.unveil ", unveil);
in the pluggin code , it works just fine for me , atleast for the purpose i am using it for .

noow i don't quite get the concept of adding the .unveil after adding the event type . WHY The .unveil ???

basically if i minify the line below :

Code: Select all

$w.on("scroll.unveil ", unveil);
to say :

Code: Select all

$w.on("scroll", unveil);
it still works fine . so whats the difference ???
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: .on Jquery Function

Post by Weirdan »

Namespace events provide a common identifier. Useful when you need to remove just those events that were attached by your plugin:

Code: Select all

$(window).off(".unveil"); // removes scroll.unveil, resize.unveil and lookup.unveil at once
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: .on Jquery Function

Post by gautamz07 »

Thanks Buddy ! That was pretty helpful .
Post Reply