Community Member Profile
- Profile: /members/4522--Cowboy-Ben-Alman.htm
- URL: http://benalman.com
- Comments: 13
- Points: 141
Recent Blog Comments By "Cowboy" Ben Alman
-
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... 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:... 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 filterin... 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... read more »
-
Using Logical Operators To Perform Ternary Operations In Javascript
Posted on Nov 18, 2009 at 11:49 AM
Another example (that Paul and I have already discussed) of where function invocation can be an issue with logical || and && is in the slide he just mentioned: data = window.JSON && JSON.parse(data) || eval('('+data+')'); If window.JSON exists, JSON.parse(data) is called.. but what if... read more »
-
Using Logical Operators To Perform Ternary Operations In Javascript
Posted on Nov 18, 2009 at 11:41 AM
@Ben, Sorry for the confusion.. the problem would be if you were actually invoking the function like: var value = "foo"; window.console && console.log( value ) || alert( value ); In that case it would both log and alert, since even though console.log exists, when it's invok... read more »
-
Using Logical Operators To Perform Ternary Operations In Javascript
Posted on Nov 18, 2009 at 11:22 AM
@Ben, this is a perfect example of where *not* to use logical && and ||: var logger = ((window.console && window.console.log) || window.alert); What if console.log returns undefined? Then it logs AND alerts. I'm guessing that's not what you want. This is probably what you want:<... read more »
-
Using Logical Operators To Perform Ternary Operations In Javascript
Posted on Nov 18, 2009 at 11:08 AM
Think about it this way: When || is encountered, if the preceding expression was truthy, evaluation stops and that truthy value is returned. When && is encountered, if the preceding expression was falsy, evaluation stops and that falsy value is returned. Otherwise, things contin... 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 »



