Programming

Try this:

document.getElementById("main").addEventListener('click', function (e) {
  if (e.target.id === "twitter-btn") {
    twttr.widgets.load( document.getElementById("twitter-sidebar") );  
  }  
}, false);

If that doesn’t work try adding console.log(e.target) above the if statement to see if the ID “twitter-btn” is in there somewhere.

Basically this is setting up an event listener to listen for a click event on an element with ID “twitter-btn” (the twitter button). But the twitter button might not even be on the page yet. So we can’t just attach the event listener to it directly. We attach it to it’s parent container which has ID “main” instead.

1 Like

This is right but might be some propagation issues iirc which is um impossibly hard to explain and why you should just stick to jquery (lol 2021).

1 Like

How do you think jquery gets around that?

https://j11y.io/jquery/#v=1.11.2&fn=jQuery.fn.on

This looks like it’s adding the event function to some kind of jQuery event object. Crazy stuff.

Thanks. I just remembered going through this before with a different button

and ended up with

$('#main').on('click', '#bar', doSomething); 

because it wasn’t in the DOM yet. I will test it tomorrow.

yeah so jquery was a fucking masterpiece of a deliverable 15 years ago, and I will never stop saying it was and still is really fucking great, but is and always has been impossible to read at a source code level to due to ridiculous structure that afaik has never been updated i.e. there’s no way to parse in your brain what is going on inside of it. And in your linked page there’s shit like this

if (fn === false) {
        fn = returnFalse;
    } else if (!fn) {
        return this;
    }

which is absolutely disasterous javascript or maybe disasterous dynamically typed code. Ahhhhhhhh.

Yeah that code pretty much seems like the poster child example for “don’t mutate or reassign your function arguments”. I assume it’s all some crazy performance optimization that isn’t necessary anymore.

I got a kick out of this:

if (one === 1) 
1 Like

I will never understand you javascript geeks but will be forever fascinated by it. What a strange, archaic language.

Come on bro, it’s beautiful.

1 Like

i feel you. having my boss tell me to understand 5,000+ lines of terraform and helm charts that was made by your russian teammate in a totally different timezone and can barely speak english, RIP

Or 1600 line bash scripts written by a guy who thinks he’s good at writing them but has like 17 piped commands in 1 line with awks and seds everywhere that are completely illegible

I wish I could explain to you guys the pain I have sometimes

1 Like

I mean, you can, right. You can know exactly, precisely, how types work in x language. This is something humans can do. But for fucks sake knowing that if (x) passes when x is a javascript number (floating point) below or above 0 OR when x is a string that is not ‘’ OR x is an a object, but not `Object.keys(x).length (something you’ll have to google the fuck out of) OR x is an array, and x is more than zero things in it

is a bit of a shitshow, or maybe a knowledge gap shitshow.

But, well, at the end of the day shitty USA #1 capitalist are paying my shitty college dropout ass a shitload of money to do their javascripts I can’t really complain, right?

2 Likes

It’s ANSI compliant so it makes no appreciable difference - queries written in ANSI compliant SQL will run in T-SQL and PostGre (though performance optimisations outside of the standard maybe be available in both of those flavours).

I was just complaining to my business partner about how feeble my IDE is in Python vs Rust. I think it’s more than just dynamic typing though. At least in my experience, IDEs are much better about JS than they are about Python. Python has the added burden that any line of code can do virtually anything at any time, in ways that aren’t comprehensible statically:

2 Likes

Any of you ever work a lot with helm charts?

Thanks this worked!

That’s more to do with there being greater demand and consequently more work put into JS than python wrt IDEs. There’s actually less magic in python vs JS though the significant whitespace adds its own wrinkle.
Speaking of IDE power, in my experience intellij for java IDE is way ahead of most other
IDEs/languagess. Have also heard that xcode for objective c/c++ is as good if not better but have never used it myself.

Query engine architecture and performance is quite different on different RDBMS. Even if one isn’t using anything outside of the ANSI standard, there can be significant differences in performance.

You’d be surprised how much non ANSI-compliant syntax there is in today’s version of TSQL. I doubt any of the code I’ve written in the last 10-15 years would run on a different RDBMS. Doubt window functions are ANSI-compliant, for example, unless the standard has been updated fairly recently.

When I say I’ll be able to figure it out, I mean mostly figuring out what part of what I know works on a different RDBMS and what doesn’t.

I stated ANSI compliant queries.

and I said this too lol.

Is this an ANSI-compliant query? Genuine question, I have no idea.

I don’t think so, iirc. Some other T-SQL syntax also isn’t.