Skip to main content

Home/ javascript/ Group items tagged callback

Rss Feed Group items tagged

Javier Neira

JQuery HowTo: Create callback functions for your jQuery plugins & extensions - 1 views

  • $.extend({  myFunc : function(someArg, callbackFnk){    // do something here    var data = 'test';     // now call a callback function    if(typeof callbackFnk == 'function'){      callbackFnk.call(this, data);    }  }});$.myFunc(someArg, function(arg){  // now my function is not hardcoded  // in the plugin itself  // and arg = 'test'});
  •  
    $.extend({ myFunc : function(someArg, callbackFnk){ // do something here var data = 'test'; // now call a callback function if(typeof callbackFnk == 'function'){ callbackFnk.call(this, data); } } }); $.myFunc(someArg, function(arg){ // now my function is not hardcoded // in the plugin itself // and arg = 'test' });
Javier Neira

Dynamically including Github code | PeterBraden.co.uk - 0 views

  •  
    /** * GitHub code inclusion * By Peter Braden */ var PBgithub = PBgithub || {}; /* You'll want to change these to your credentials */ PBgithub.login = "peterbraden"; PBgithub.token = "9d567812a941dc331cf4e431e7fc4ebc"; PBgithub.base = "http://github.com/api/v2/json/"; /** Load github content for this code element **/ PBgithub.codify= function(code_elem){ PBgithub.c = $(code_elem); $.getScript(PBgithub.make_url(PBgithub.base + 'repos/show/', "/branches", 'PBgithub.handle_branch')); } PBgithub.make_url = function(front, end, callback){ var data = "?callback=" + callback + "&login=" + PBgithub.login + "&token=" + PBgithub.token; return front + PBgithub.c.attr('username') + "/" + PBgithub.c.attr('repository') + end + data; } PBgithub.handle_file = function(data){ PBgithub.c.html( data['blob']['data'].replace(//g, '>')); PBgithub.next(); } PBgithub.handle_branch = function(data){ var branch = data['branches'][PBgithub.c.attr('branch')]; $.getScript(PBgithub.make_url(PBgithub.base + 'blob/show/', "/" + branch + "/" + PBgithub.c.attr('path'), 'PBgithub.handle_file')); } PBgithub.next = function(){ if (PBgithub.i < PBgithub.elems.length){ PBgithub.i+=1; PBgithub.codify(PBgithub.elems.get(PBgithub.i-1)); } } $(function(){ PBgithub.i = 0; PBgithub.elems = $('code.from-github'); PBgithub.next(); });
Julian Knight

JQuery Cycle Plugin - 1 views

  •  
    "The jQuery Cycle Plugin is a lightweight slideshow plugin. Its implementation is based on the InnerFade Plugin by Torsten Baldes, the Slideshow Plugin by Matt Oakes, and the jqShuffle Plugin by Benjamin Sterling. It supports pause-on-hover, auto-stop, auto-fit, before/after callbacks, click triggers and many transition effects. It also supports, but does not require, the Metadata Plugin and the Easing Plugin." This is one that really works and is genuinely easy to set up - no complex CSS like so many of these things. It also works very well with just text or other HTML structures.
Javier Neira

Understanding JavaScript Timers « JavaScript, JavaScript - 1 views

  • By enforcing a timeout (however small) you remove the function from the current execution queue and hold it back until the browser is not busy.
  • you can make long running functions (on which no other immediate function is dependent) defer execution until more urgent routines have completed.
  • The firing of the setTimeout callback is asynchronous, the function itself will be invoked in line and after the current invocation queue
Javier Neira

JavaScript setTimeout Function - JavaScript Timing Events - 0 views

  •  
    JavaScript setTimeout Function - JavaScript Timing Events November 16, 2007 by Blogging Developer JavaScript features a couple of methods that lets you run a piece of JavaScript code (javascript function) at some point in the future. These methods are: * setTimeout() * setInterval() In this tutorial, I'll explain how setTimetout() method works, and give a real world example. You may find the details of setInterval() method in JavaScript setInterval Function - JavaScript Timing Events setTimeout() window.setTimeout() method allows you to specify a piece of JavaScript code (expression) will be run after specified number of miliseconds from when the setTimeout() method is called. Syntax var t = setTimeout ( expression, timeout ); The setTimeout() method returns a numeric timeout ID which can be used to refer the timeout to use with clearTimeout method. The first parameter (expression) of setTimeout() is a string containing a javascript statement. The statement could be a call to a JavaScript function like "delayedAlert();" or a statement like "alert('This alert is delayed.');". The second parameter (timeout), indicates the number of miliseconds to pass before executing the expression. Example An alert box will be shown 5 seconds later when you clicked the button. clearTimeout() Sometimes it's useful to be able to cancel a timer before it goes off. The clearTimeout() method lets us do exactly that. Its syntax is: clearTimeout ( timeoutId ); where timeoutId is the ID of the timeout as returned from the setTimeout() method call.
1 - 5 of 5
Showing 20 items per page