Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 27 2017 02:46
    davedub opened #19
  • Dec 27 2017 02:46
    davedub opened #19
  • Dec 27 2017 02:43
    davedub edited #6
  • Dec 27 2017 02:43
    davedub edited #6
  • Dec 27 2017 02:40
    davedub closed #6
  • Dec 27 2017 02:40
    davedub closed #6
  • Dec 27 2017 02:38
    davedub opened #6
  • Dec 27 2017 02:38
    davedub opened #6
  • Mar 25 2015 16:20

    brookr on master

    (markup) wrap code spans w/ bac… Merge pull request #16 from fra… (compare)

  • Mar 25 2015 16:20

    brookr on master

    (markup) wrap code spans w/ bac… Merge pull request #16 from fra… (compare)

  • Mar 25 2015 16:20
    brookr closed #16
  • Mar 25 2015 16:20
    brookr closed #16
  • Mar 25 2015 16:20
    brookr commented #16
  • Mar 25 2015 16:20
    brookr commented #16
  • Mar 25 2015 16:18
    brookr commented #17
  • Mar 25 2015 16:18
    brookr commented #17
  • Mar 25 2015 16:18

    brookr on master

    (markup) improve superagent mar… Merge pull request #17 from fra… (compare)

  • Mar 25 2015 16:18

    brookr on master

    (markup) improve superagent mar… Merge pull request #17 from fra… (compare)

  • Mar 25 2015 16:18
    brookr closed #17
  • Mar 25 2015 16:18
    brookr closed #17
Erik Nilsen
@enilsen16
@bwstud you see my message
Brian Studwell
@bwstud
negative
Robert Talamantez
@Talamantez
@kevinmstephens got it figured out- over complicating things again
Andy Ernst
@AndyCErnst

Here's something I don't understand. Why does this

elements[i].onclick = makeHandler(i+1); 
var makeHandler = function(num) {  
              console.log("This is element #" + num);
}

behave differently than

elements[i].onclick = function(){console.log(i+1)}
This was in a code snibbit to demonstrate that you can't reference an iterator (the i) inside a for loop. The .onclick parts were inside for loops. But the part I don't get is why in the first one the function execute immediately, but in the second one it waits for the click event.
To fix this they made the function return a function
var makeHandler = function(num) {  
     return function() {
         console.log("This is element #" + num);
     };
};
Robert Talamantez
@Talamantez
maybe you have to do a prevent default to stop the first function from running right away
Andy Ernst
@AndyCErnst
http://jsfiddle.net/AfmA5/ if you want to mess around with it
In jQuery you would prevent default by taking in the event and calling preventDefault on it but this isn't jQuery. I don't think the event is passed anywhere and I'm not sure that's the problem
Tyler Morgan
@toastynerd
Whenever you add () to a function that’s already declared it calls it, if it’s an anonymous function it’s a declaration and you have to add the () to call it.
you could also do something like this:
elements[i].onclick = function() { makeHandler(i+1)};
and not have the return function in there
it’s a process called currying
Andy Ernst
@AndyCErnst
I've never really gotten my head around functions returning functions (unless they are constructors or something)
Tyler Morgan
@toastynerd
Yeah, it’s a little weird but it lets you pass a function by reference instead of calling the function.
well, I should say it lets you passs you a function with arguments by reference
Andy Ernst
@AndyCErnst
And Robert, I figured out how to grab the event http://jsfiddle.net/AfmA5/1/ I thought it was working differently than jQuery but you were right
Robert Talamantez
@Talamantez
cool
Andy Ernst
@AndyCErnst

How about this one

function addClickHandler(element) {
    element.click = function onClick(e) {
        alert("Clicked the " + element.nodeName)
    }
}

I understand how it's a circular reference with element referencing itself but I don't how how to eliminate it

Tyler Morgan
@toastynerd
it doesn’t have to be, you can get rid of that e, you’re not using it anywhere
Anna Luisa Patiño West
@aisapatino
@KuroFluff is the problem you're having that element is undefined or referencing the wrong thing within that function? i think you can also access the element through the jquery event object - something like e.target should work (so replace element.nodeName with e.target.nodeName)
Andy Ernst
@AndyCErnst
The e is not important in this one. The problem is that element.click has a ref to element.nodeName and according to the site I pulled this from that's element linking itself, which is a circular reference.
As they say, "Don't miss the forest for the Es"
Or was that trees?
Tyler Morgan
@toastynerd
@KuroFluff lol, do you have a repo up somewhere, it’s hard to know what’s going on without seeing the context.
Andy Ernst
@AndyCErnst
http://t.co/Rst6WUEvhq it's from an article 10 Most Common JavaScript Mistakes, #3 example 2
Unless this guy is totally off-base?
Hmm, apparently writing "#3" links to a PR request in github
Josh Cunningham
@joshcanhelp

Hey everyone! Hope all is well in Node-land. I just finished up a little project this weekend that I wanted to share. It's a cocktail manager app for keeping track of my growing list of tasty adult beverages. Not currently using any MVC frameworks, just jQuery, but after cleaning everything up, my plan is to try them all out in different branches.

https://github.com/joshcanhelp/cocktail-manager

Feedback, questions, pull requests, issues, and stars are all welcome!

I also parsed out all of our homework and reading links from the class into a MD file in case anyone needs a reference. I added a few supplementary ones that I found helpful as well:

https://github.com/joshcanhelp/codefellows-link-stash

Zach Bryan
@ZBryan
That is awesome thanks for grabbing all the links! I will explore the adult beverage on tonight, nice work man
Robert Talamantez
@Talamantez
thanks Josh!
Josh Cunningham
@joshcanhelp
No prob ... hope one or both is helpful!
Robert Talamantez
@Talamantez
Hey Josh, I had to manually install jade and cookie-parser, so maybe drop those into the package.json?
the font is totally awesome btw
Josh Cunningham
@joshcanhelp
derp ... Jade is global on mine, thanks for the heads up
Robert Talamantez
@Talamantez
did i really go through 8 weeks of code school and not use jade?
Josh Cunningham
@joshcanhelp
I like it a lot. Needs much more/better docs but an interesting way to write HTML
Not everyone is a fan though
Tyler Morgan
@toastynerd
Me, I’m not a fan.
Robert Talamantez
@Talamantez
It's all I used before codefellows
Josh Cunningham
@joshcanhelp
^^ that guy :)
Robert Talamantez
@Talamantez
mostly because all the tutorials used it
Josh Cunningham
@joshcanhelp
I'll say that there were a few things where I was like "WTAF" but, for the most part, I really liked it. That combined with Sass feels like a very easy way to bang out HTML + CSS
Robert Talamantez
@Talamantez
This message was deleted
Tyler Morgan
@toastynerd
The problem I have with jade is it makes it more difficult for anyone who’s not a node developer to work on your front end.
plus spaces have sytantic meaning and I hate that shit
Robert Talamantez
@Talamantez
I still need to take the Sass class
Also - Josh - you should pipe in google images based on the names of the drinks amirite?