A page in a web application shows formatted objects, menus, or things that pertain directly to the application domain. Like lists of objects from the database, or a single object, selected from the database and presented to the user. Lists of objects, or a single object, are part of the link the user has clicked, or pasted into the browser address bar. No matter actually, it's the notion uniform resource identification — the mechanism realizing this idea is secondary. The goal is that the link text identifies a resource within the application. But is that the extent of the information encoded into a single URI? Or do applications, as they become more sophisticated from a user interface perspective, need to provide context to the pages that render these URIs?
Showing posts with label context. Show all posts
Showing posts with label context. Show all posts
Wednesday, January 9, 2013
Monday, May 31, 2010
jQuery String Contexts
The jQuery.each() iteration function is a powerful Javascript iteration utility. You supply a callback function that is executed for each element in the provided set. Additionally, the this object in the callback function is the current element. This can cause some subtle bugs in your code if your doing string comparisons.
Since this is an object and your callback wants to do a comparison as though this were a string, it will not always evaluate to true. Even when it should be. I found this rather annoying so I tried to make sure I was in fact comparing two strings. Sure enough, this.toString() fixed my problem. So, try using this if your strings aren't evaluating as expected inside jQuery.each() callbacks.
Since this is an object and your callback wants to do a comparison as though this were a string, it will not always evaluate to true. Even when it should be. I found this rather annoying so I tried to make sure I was in fact comparing two strings. Sure enough, this.toString() fixed my problem. So, try using this if your strings aren't evaluating as expected inside jQuery.each() callbacks.
Subscribe to:
Posts
(
Atom
)