Created
November 18, 2010 10:20
-
-
Save mklabs/704835 to your computer and use it in GitHub Desktop.
Example of what not to do when writing jQuery code (well it begins by following js is a hack... pretty explicit...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // the following javascript is a hack to display a "file" image instead of a "folder" image | |
| // when an entity has no children to display. | |
| var ulList = $('ul'); | |
| for (i=0; i<ulList.length; i++) { | |
| var ulEl = ulList[i]; | |
| if ($('li[class!=liToHide]', ulEl).length == 0) { | |
| var spanEl = $(ulEl).prev().prev(); | |
| var imgList = $('img', spanEl); | |
| $(imgList[0]).attr('src', Constants.LI_IMG_URL); | |
| $(imgList[1]).attr('src', Constants.FILE_IMG_URL); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment