Coder Social home page Coder Social logo

cowboy / jquery-dotimeout Goto Github PK

View Code? Open in Web Editor NEW
273.0 16.0 34.0 320 KB

jQuery doTimeout: Like setTimeout, but better!

Home Page: http://benalman.com/projects/jquery-dotimeout-plugin/

License: GNU General Public License v2.0

PHP 5.43% JavaScript 94.57%

jquery-dotimeout's Introduction

jQuery doTimeout: Like setTimeout, but better!

http://benalman.com/projects/jquery-dotimeout-plugin/

Version: 1.0, Last updated: 3/3/2010

jQuery doTimeout takes the work out of delayed code execution, including interval and timeout management, polling loops and debouncing. In addition, it's fully jQuery chainable, with a very simple, yet powerful API.

Visit the project page for more information and usage examples!

Documentation

http://benalman.com/code/projects/jquery-dotimeout/docs/

Examples

These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.

http://benalman.com/code/projects/jquery-dotimeout/examples/debouncing/
http://benalman.com/code/projects/jquery-dotimeout/examples/delay-poll/
http://benalman.com/code/projects/jquery-dotimeout/examples/hoverintent/

Support and Testing

Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).

jQuery Versions

1.3.2, 1.4.2

Browsers Tested

Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1.

Unit Tests

http://benalman.com/code/projects/jquery-dotimeout/unit/

Release History

1.0 - (3/3/2010) Callback can now be a string, in which case it will call the appropriate $.method or $.fn.method, depending on where .doTimeout was called. Callback must now return true (not just a truthy value) to poll.
0.4 - (7/15/2009) Made the "id" argument optional, some other minor tweaks
0.3 - (6/25/2009) Initial release

License

Copyright (c) 2010 "Cowboy" Ben Alman
Dual licensed under the MIT and GPL licenses.
http://benalman.com/about/license/

jquery-dotimeout's People

Contributors

cowboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-dotimeout's Issues

New feature to force_mode call

I'd like to propose a new feature for doTimeout to get around a problem that I've found on IE (8) and Chrome. Here is an example of the code with a comment about the problem :

http://jsfiddle.net/d2HLc/6/

Essentially the problem is I need to call $.doTimeout("id_of_function", true); with a delay so the first call (in my case a call to an Ajax function) succeeds. Without the delay I always get the error callback from the Ajax function. What I'm doing to get resolve this now is this:

setTimeout('$.doTimeout("id_of_function", true);', 500);

Thanks for your help!
Doug

Feature: call jQuery method/plugin

I'd like to propose a new signature for the doTimeout.

// call $('div').hide() after 2 seconds
$('div').show().doTimeout(2000, 'hide');

[enhancement] Add missing bower.json.

Hey, maintainer(s) of cowboy/jquery-dotimeout!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library cowboy/jquery-dotimeout is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "cowboy/jquery-dotimeout",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Long running script

Dear Ben,

I got the following error in IE8 after a long running test with a page open for about six hours. Obviously it's not a common error if the script has been running out the page fine for the previous six hours.

Message: Object doesn't support this property or method
Line: 240
Char: 41
Code: 0
URI: http://www.stakemydog.com/Scripts/jquery-dotimeout/jquery.ba-dotimeout.js

I'm assuming it's referring to this function:

// Yes, there actually is a setTimeout call in here!
function actually_setTimeout() {
data.id = setTimeout( function(){ data.fn(); }, delay );
};

I'm guessing that data doesn't have the function fn defined. Do you have any idea what could be causing this or where to start debugging?

Regards Giles.

Problems when called from inside a handler

Great plugin! One issue:

In this example:

$.doTimeout("foo", 100, function() {
    log("in");
    $.doTimeout("foo", 1000, function() {
        log("out");
    });
});

... the inner doTimeout should clear away any others with the same ID, but it does not. Wrapping the inner doTimeout in a setTimeout fixes it, so I assume it has to do with setting up a new doTimeout from within its own handler.

Minimal test case:

http://jsfiddle.net/MmJwj/

I suppose it may look contrived, but it's from a real use-case; I can give more detail if needed.

Thanks.

Does not work on on change

I'm trying to debounce a number field but with the on change event it just doesn't work. You can get round this by using on mouseup, keyup, but then when you select what's in the input box it then triggers which I don't want.

Example of it not working here:
https://jsfiddle.net/xpvt214o/320184/

When you keep clicking up for example it just submits after the first change and doesn't cancel each time you click

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.