Timeline for jQuery script to toggle an element and handle a Close button
Current License: CC BY-SA 3.0
21 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 22, 2016 at 20:21 | history | edited | 200_success | CC BY-SA 3.0 |
added 1 character in body; edited tags; edited title
|
May 12, 2012 at 16:36 | vote | accept | r0skar | ||
Nov 11, 2011 at 14:47 | comment | added | DisgruntledGoat |
@Andrej I thought that may be the case but I was confused how .[attr] actually selected anything at all, unless it was a special character somehow (it's normally used for class selection). So yes, [attr] is the same as *[attr] - or in the more general sense: * is only necessary when alone and not combined with any other selectors.
|
|
Nov 11, 2011 at 11:51 | comment | added | r0skar |
@DisgruntledGoat: Thanks for your input! I initially thought it might be a good idea to add it to target all elements, which have the data attribute. But due to your comment and after testing it, I removed it now, because it works just fine for all elements without *.
|
|
Nov 10, 2011 at 23:25 | comment | added | DisgruntledGoat |
What does the *. part do in those first three selectors?
|
|
Nov 10, 2011 at 20:31 | answer | added | DADU | timeline score: 3 | |
Nov 10, 2011 at 17:43 | vote | accept | r0skar | ||
May 12, 2012 at 16:36 | |||||
Nov 10, 2011 at 17:24 | answer | added | kojiro | timeline score: 2 | |
Nov 10, 2011 at 17:20 | history | tweeted | twitter.com/#!/StackCodeReview/status/134681953466204160 | ||
Nov 10, 2011 at 17:09 | comment | added | r0skar | @kojiro: Did that! Thanks for all your support. | |
Nov 10, 2011 at 17:08 | history | edited | r0skar | CC BY-SA 3.0 |
updated script with "lint free" version
|
Nov 10, 2011 at 17:05 | comment | added | kojiro | @Andrej it means your script is lint-free and that if there are logic errors or other problems they'll be easier to pick out. So now, update your above code to the lint-free version. | |
Nov 10, 2011 at 16:58 | comment | added | r0skar | @kojiro: Following your advices, I have eliminated all errors and warnings and Lint gives me a "Good Job" :) - but this doesnt mean the script is well-written and efficient, does it? | |
Nov 10, 2011 at 16:56 | comment | added | cHao | @Andrej: If you like the idea of saying "hey, JavaScript, help me write better code", then try it out. Personally, i don't use it...but i can see where it might provide some huge benefits (assuming it's watching for actual common flaws and not just style issues). | |
Nov 10, 2011 at 16:53 | comment | added | r0skar | @cHao: Thanks for the explanation. So would you suggest to basically always use it in every script by putting it on top of any .js file? | |
Nov 10, 2011 at 16:51 | comment | added | kojiro |
Here's some information on strict mode. If you decide not to use it, you can turn it off in the linter's options. Get rid of the extra semicolons and read about the difference between function declarations and function expressions. As for smoothScrolling , you can just tell the linter that it's a global, and it won't complain anymore.
|
|
Nov 10, 2011 at 16:48 | comment | added | cHao |
"use strict" is a feature of newer versions of JS. It means to make sure you're not doing a bunch of stuff that people accidentally do that causes lots of headaches. To use it, basically, you put that string (just that string; no var, no whatever=, none of that. just "use strict"; ) as the first line of your function, and then fix all the errors you'll probably get. :)
|
|
Nov 10, 2011 at 16:41 | comment | added | r0skar | Oh and one more thing: "Line 3: var toggleOpen = $('*.[data-toggle="open"]'); Missing "use strict" statement." I am not sure what this means and how to solve it... | |
Nov 10, 2011 at 16:39 | comment | added | r0skar | @kojiro No, actually its the first time I heard of this tool and thanks a lot for sharing!! After doing it: I get a couple of "Unnecessary semicolon" (I´d like to keep them though - in case they dont have any negative impact?). And "'smoothScrolling' is not defined." (thats because this function is outside my pasted example, but it does ofc exist in my whole code). Thanks again for sharing that tool! | |
Nov 10, 2011 at 16:21 | comment | added | kojiro | Before I get started reviewing, have you linted your code? | |
Nov 10, 2011 at 15:58 | history | asked | r0skar | CC BY-SA 3.0 |