"Cowboy" Ben Alman
Member since Oct 13, 2009
- Profile: /members/4522-cowboy-ben-alman.htm
- URL: http://benalman.com/
- Comments: 19
Recent Blog Comments By "Cowboy" Ben Alman
-
Empty SRC And URL() Values Can Cause Duplicate Page Requests
Posted on Aug 4, 2011 at 11:59 AM
Ben, check out this article by Nicholas Zakas: http://www.nczonline.net/blog/2009/11/30/empty-image-src-can-destroy-your-site/... read more »
-
Experimenting With Sub() And Deferred Objects In jQuery 1.5
Posted on Feb 17, 2011 at 10:48 AM
Ben, check out this gist for another way to use $.sub: https://gist.github.com/804811... read more »
-
Using SetTimeout() To Delay The Closing Of A Related UI Element Based On User Interactions
Posted on Oct 4, 2010 at 11:15 AM
Ben, take a look at my jQuery doTimeout plugin, which is very useful for delayed code execution, especially when dealing with polling loops or hover intent: http://benalman.com/projects/jquery-dotimeout-plugin/ In addition, my jQuery throttle / debounce plugin is geared towards rate-limiting fun... read more »
-
Using Named Functions Within Self-Executing Function Blocks In Javascript
Posted on Aug 16, 2010 at 10:44 AM
One caveat to this method is that it doesn't work in BlackBerry OS 5.x or earlier, as the code inside the named function expression can't access the the function by name (for whatever reason). So, if you're writing cross-OS mobile JavaScript, you should avoid this pattern. See http://github.com/co... read more »
-
Experimenting With jQuery's Queue() And Dequeue() Methods
Posted on Jun 17, 2010 at 6:46 PM
@tylik, it might be more helpful if you fork my gist on GitHub and ask your question there, so that we get the benefit of syntax highlighting, indenting, comments and revisions. http://gist.github.com/319568... read more »
-
Javascript's IN Operator Does Not Work With Strings
Posted on May 11, 2010 at 8:50 AM
Why not just test if ( typeof arg === 'string' ) { ... } ?... read more »
-
Experimenting With jQuery's Queue() And Dequeue() Methods
Posted on Mar 2, 2010 at 10:14 AM
BTW, here's my code as a gist for easier viewing: http://gist.github.com/319568... read more »
-
Experimenting With jQuery's Queue() And Dequeue() Methods
Posted on Mar 2, 2010 at 10:09 AM
@Ben, I like SyntaxHighlighter personally.. you can see it in my site's comments, plugin code examples, etc. Easy to use and flexible. http://alexgorbatchev.com/wiki/SyntaxHighlighter Regarding the queueing stuff, I actually wrote a plugin to manage queues, but it works a bit differently than jQ... read more »
-
Experimenting With jQuery's Queue() And Dequeue() Methods
Posted on Mar 2, 2010 at 9:47 AM
Man, I wish there was comment code syntax highlighting.... read more »
-
Experimenting With jQuery's Queue() And Dequeue() Methods
Posted on Mar 2, 2010 at 9:47 AM
It's especially useful when have a series of asynchronous method calls that you want to execute serially, and don't want to maintain a chain of callbacks. Say you want to execute first_async_action() followed by second_async_action(), followed by third_async_action(). You could do this: <pre>... read more »
-
Selecting The Closest Parent On Multiple Nodes With The jQuery Plugin ClosestParents()
Posted on Feb 15, 2010 at 10:54 AM
@Ben, I haven't done any testing, but I'm sure that: jQuery( node ).parent().closest( selector ) will be faster than: jQuery( node ).parents( selector ).first() because while .parents() collects *all* parent elements, traversing all the way up the hierarchy before filtering its results with .fir... read more »
-
Selecting The Closest Parent On Multiple Nodes With The jQuery Plugin ClosestParents()
Posted on Feb 15, 2010 at 9:50 AM
Gotcha, makes sense!... read more »
-
Selecting The Closest Parent On Multiple Nodes With The jQuery Plugin ClosestParents()
Posted on Feb 15, 2010 at 9:38 AM
Hey Ben, instead of: result = result.add( jQuery( node ).parents( selector ).first() ); Why not do: result = result.add( jQuery( node ).closest( selector ) );... read more »
-
Creating A Sometimes-Fixed-Position Element With jQuery
Posted on Jan 12, 2010 at 10:40 AM
I like the approach where the element starts with a position: static (rendered in the normal flow of the document) and when the page is scrolled away from the top (or past the element's top offset), the element gets position: fixed. Of course, that doesn't work in IE6.. so you have to test for tha... read more »
-
jQuery Plugin: From - Filtering A Collection Based On Ancestors
Posted on Oct 13, 2009 at 1:53 PM
Ben, looks useful. One suggestion though, I'd love to see your code include a private from method that both $.fn.from and $.expr[':'].from utilize. That way you could use from as both a method and a psuedo-selector!... read more »