Merged the three unbind docs into one, added a few more (optional) hints; Use one() instead of bind() for unload

This commit is contained in:
Jörn Zaefferer 2007-01-04 09:47:42 +00:00
parent e0c7e6aec4
commit df91317ab4
2 changed files with 29 additions and 41 deletions

View file

@ -265,8 +265,22 @@ jQuery.fn.extend({
/**
* The opposite of bind, removes a bound event from each of the matched
* elements. You must pass the identical function that was used in the original
* bind method.
* elements.
*
* Without any arguments, all bound events are removed.
*
* If the type is provided, all bound events of that type are removed.
*
* If the function that was passed to bind is provided as the second argument,
* only that specific event handler is removed.
*
* @example $("p").unbind()
* @before <p onclick="alert('Hello');">Hello</p>
* @result [ <p>Hello</p> ]
*
* @example $("p").unbind( "click" )
* @before <p onclick="alert('Hello');">Hello</p>
* @result [ <p>Hello</p> ]
*
* @example $("p").unbind( "click", function() { alert("Hello"); } )
* @before <p onclick="alert('Hello');">Hello</p>
@ -274,34 +288,8 @@ jQuery.fn.extend({
*
* @name unbind
* @type jQuery
* @param String type An event type
* @param Function fn A function to unbind from the event on each of the set of matched elements
* @cat Events
*/
/**
* Removes all bound events of a particular type from each of the matched
* elements.
*
* @example $("p").unbind( "click" )
* @before <p onclick="alert('Hello');">Hello</p>
* @result [ <p>Hello</p> ]
*
* @name unbind
* @type jQuery
* @param String type An event type
* @cat Events
*/
/**
* Removes all bound events from each of the matched elements.
*
* @example $("p").unbind()
* @before <p onclick="alert('Hello');">Hello</p>
* @result [ <p>Hello</p> ]
*
* @name unbind
* @type jQuery
* @param String type (optional) An event type
* @param Function fn (optional) A function to unbind from the event on each of the set of matched elements
* @cat Events
*/
unbind: function( type, fn ) {
@ -1090,7 +1078,7 @@ new function(){
// Clean up after IE to avoid memory leaks
if (jQuery.browser.msie)
jQuery(window).bind("unload", function() {
jQuery(window).one("unload", function() {
var global = jQuery.event.global;
for ( var type in global ) {
var els = global[type], i = els.length;

View file

@ -73,7 +73,7 @@ jQuery.fn.extend({
*
* @name slideDown
* @type jQuery
* @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback (optional) A function to be executed whenever the animation completes.
* @cat Effects/Animations
* @see slideUp(String|Number,Function)
@ -98,7 +98,7 @@ jQuery.fn.extend({
*
* @name slideUp
* @type jQuery
* @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback (optional) A function to be executed whenever the animation completes.
* @cat Effects/Animations
* @see slideDown(String|Number,Function)
@ -123,13 +123,13 @@ jQuery.fn.extend({
*
* @name slideToggle
* @type jQuery
* @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback (optional) A function to be executed whenever the animation completes.
* @cat Effects/Animations
* @see slideDown(String|Number,Function)
* @see slideUp(String|Number,Function)
*/
slideToggle: function(speed,callback){
slideToggle: function(speed, callback){
return this.each(function(){
var state = jQuery(this).is(":hidden") ? "show" : "hide";
jQuery(this).animate({height: state}, speed, callback);
@ -152,13 +152,13 @@ jQuery.fn.extend({
*
* @name fadeIn
* @type jQuery
* @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback (optional) A function to be executed whenever the animation completes.
* @cat Effects/Animations
* @see fadeOut(String|Number,Function)
* @see fadeTo(String|Number,Number,Function)
*/
fadeIn: function(speed,callback){
fadeIn: function(speed, callback){
return this.animate({opacity: "show"}, speed, callback);
},
@ -178,13 +178,13 @@ jQuery.fn.extend({
*
* @name fadeOut
* @type jQuery
* @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback (optional) A function to be executed whenever the animation completes.
* @cat Effects/Animations
* @see fadeIn(String|Number,Function)
* @see fadeTo(String|Number,Number,Function)
*/
fadeOut: function(speed,callback){
fadeOut: function(speed, callback){
return this.animate({opacity: "hide"}, speed, callback);
},
@ -238,8 +238,8 @@ jQuery.fn.extend({
* @name animate
* @type jQuery
* @param Hash params A set of style attributes that you wish to animate, and to what end.
* @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback A function to be executed whenever the animation completes.
* @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
* @param Function callback (optional) A function to be executed whenever the animation completes.
* @cat Effects/Animations
*/
animate: function(prop,speed,callback) {