• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 21:52
CET 03:52
KST 11:52
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT28Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (Feb 16-22): MaxPax doubles0Weekly Cups (Feb 9-15): herO doubles up2ACS replaced by "ASL Season Open" - Starts 21/0258LiuLi Cup: 2025 Grand Finals (Feb 10-16)46Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2
StarCraft 2
General
MMOexp Diablo4 exploring the edges of swamps MMOexp FC26 rounds out the forward recommendations Terran AddOns placement How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Nexon's StarCraft game could be FPS, led by UMS maker
Tourneys
PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) Sparkling Tuna Cup - Weekly Open Tournament SEL Doubles (SC Evo Bimonthly) WardiTV Team League Season 10 RSL Season 4 announced for March-April
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 515 Together Forever Mutation # 514 Ulnar New Year Mutation # 513 Attrition Warfare
Brood War
General
Soma Explains: JD's Unrelenting Aggro vs FlaSh Recent recommended BW games TvZ is the most complete match up BGH Auto Balance -> http://bghmmr.eu/ ACS replaced by "ASL Season Open" - Starts 21/02
Tourneys
BWCL Season 64 Announcement The Casual Games of the Week Thread [Megathread] Daily Proleagues [LIVE] [S:21] ASL Season Open Day 1
Strategy
Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Simple Questions, Simple Answers Zealot bombing is no longer popular?
Other Games
General Games
Online Quake Live Config Editor Tool Battle Aces/David Kim RTS Megathread Diablo 2 thread Nintendo Switch Thread Path of Exile
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine UK Politics Mega-thread YouTube Thread Mexico's Drug War
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Inside the Communication of …
TrAiDoS
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2880 users

The Big Programming Thread - Page 945

Forum Index > General Forum
Post a Reply
Prev 1 943 944 945 946 947 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 12 2018 17:59 GMT
#18881
microsofts c++ compiler gives me so much grief.
what a dream it would be to work with gcc.
conspired against by a confederacy of dunces.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
February 13 2018 17:09 GMT
#18882
No mention of intel c++? It's been a while, but damn, that difference in performance back then...
If you have a good reason to disagree with the above, please tell me. Thank you.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 13 2018 19:18 GMT
#18883
On February 14 2018 02:09 spinesheath wrote:
No mention of intel c++? It's been a while, but damn, that difference in performance back then...

Has anybody here ever worked with an intel compiler? I know they generate faster binaries, however never heard how they compare with regards to other aspects like error handling.
The harder it becomes, the more you should focus on the basics.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2018-02-14 17:33:37
February 14 2018 17:32 GMT
#18884
I compared performance of ms, gcc and intel compiled code for a molecular dynamics simulation as part of my bachelor's thesis. The software ran on the lrz cluster in munich. Obviously I wasn't very concerned with other aspects, but for performance, it was a rather clear intel > ms > gcc.

Also intel's performance analysis tools were awesome.
If you have a good reason to disagree with the above, please tell me. Thank you.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-02-14 22:08:17
February 14 2018 21:42 GMT
#18885
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!
Lmui
Profile Joined November 2010
Canada6222 Posts
Last Edited: 2018-02-14 22:24:44
February 14 2018 22:22 GMT
#18886
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!


Open up the Chrome console when you click it - it shows this:

Uncaught SyntaxError: Unexpected token < .(index):67

The issue is with the apostrophe in "Doesn't"

Remove the apostrophe and it works (or escape it).

edit:: Nvm - still syntax errors
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 14 2018 22:33 GMT
#18887
On February 15 2018 07:22 Lmui wrote:

Open up the Chrome console when you click it - it shows this:

Uncaught SyntaxError: Unexpected token < .(index):67

The issue is with the apostrophe in "Doesn't"

Remove the apostrophe and it works (or escape it).

edit:: Nvm - still syntax errors

I'm using chrome and don't get any syntax errors. I tried removing the apostrophe, and still no luck.
tofucake
Profile Blog Joined October 2009
Hyrule19193 Posts
Last Edited: 2018-02-14 22:44:24
February 14 2018 22:37 GMT
#18888
https://jsfiddle.net/dnz5kc6c/29/

using .on like that only works for elements on the page at load. You have to do
$(document).on('click', 'selector', function() {});
to attach events to inserted elements

jquery changed from an old way of doing things to new in 1.7 and basically just overloaded .on to do 3 separate things depending on arguments.

see http://api.jquery.com/bind/ (what you were doing) vs http://api.jquery.com/delegate/ (what you needed to be doing)
Liquipediaasante sana squash banana
Lmui
Profile Joined November 2010
Canada6222 Posts
February 14 2018 22:40 GMT
#18889
On February 15 2018 07:33 enigmaticcam wrote:
Show nested quote +
On February 15 2018 07:22 Lmui wrote:

Open up the Chrome console when you click it - it shows this:

Uncaught SyntaxError: Unexpected token < .(index):67

The issue is with the apostrophe in "Doesn't"

Remove the apostrophe and it works (or escape it).

edit:: Nvm - still syntax errors

I'm using chrome and don't get any syntax errors. I tried removing the apostrophe, and still no luck.


From Chrome -> F12, there's a tab called "Event Listeners"

The new button doesn't have the onclick event listener associated.

https://stackoverflow.com/questions/21968922/how-to-add-script-to-a-button-in-html-in-same-file

Found this - I guess you need to add the on-click event to the new button.
Acrofales
Profile Joined August 2010
Spain18224 Posts
February 14 2018 22:42 GMT
#18890
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!

Your button is between script tags, for starters.

Easiest way of doing this is setting it to display:none at the start and then toggling it in your javascript.

But the syntax error is because your button is inside the script tags. And the button is html, not javascript.
Excludos
Profile Blog Joined April 2010
Norway8233 Posts
February 14 2018 22:50 GMT
#18891
On February 15 2018 07:42 Acrofales wrote:
Show nested quote +
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!

Your button is between script tags, for starters.

Easiest way of doing this is setting it to display:none at the start and then toggling it in your javascript.

But the syntax error is because your button is inside the script tags. And the button is html, not javascript.


That doesn't matter. Html inserts from script is fine. What does matter, however, is what tofucake pointed out. Button isn't initiated from start, and thus the onclick in its current form won't work.

Generally tho, inserting elements after the fact isn't a good practice to begin with. If possible you want to load everything at start, and show/hide. Obviously doesn't matter much for just a single button, but loading in elements after the fact makes for a slower page and bad user experience.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 14 2018 23:00 GMT
#18892
I had a div that I wanted to show one of several different things depending on what the user clicks. Initially I thought I could just put each individual thing in a separate script and insert it into the div. But perhaps it would be better to have them all as hidden divs inside the parent div, and just show/hide what I need?
Acrofales
Profile Joined August 2010
Spain18224 Posts
Last Edited: 2018-02-14 23:19:39
February 14 2018 23:19 GMT
#18893
On February 15 2018 07:50 Excludos wrote:
Show nested quote +
On February 15 2018 07:42 Acrofales wrote:
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!

Your button is between script tags, for starters.

Easiest way of doing this is setting it to display:none at the start and then toggling it in your javascript.

But the syntax error is because your button is inside the script tags. And the button is html, not javascript.


That doesn't matter. Html inserts from script is fine. What does matter, however, is what tofucake pointed out. Button isn't initiated from start, and thus the onclick in its current form won't work.

Generally tho, inserting elements after the fact isn't a good practice to begin with. If possible you want to load everything at start, and show/hide. Obviously doesn't matter much for just a single button, but loading in elements after the fact makes for a slower page and bad user experience.

I was referring to this bit:

<script id="MenuOption1" type="text/javascript">
<button type="button" class="MyButton">Doesn't Work</button>
</script>


That doesn't insert a button. That just gives a syntax error. Of course you *can* insert a button with javascript, but that's not how you do it. Other than that, we're in agreement.
Acrofales
Profile Joined August 2010
Spain18224 Posts
February 15 2018 00:11 GMT
#18894
On February 15 2018 08:00 enigmaticcam wrote:
I had a div that I wanted to show one of several different things depending on what the user clicks. Initially I thought I could just put each individual thing in a separate script and insert it into the div. But perhaps it would be better to have them all as hidden divs inside the parent div, and just show/hide what I need?

Probably, yes. Or maybe you want to divide your page up into different parts, which you can then load with Ajax, depending on what the user wants to see. Without it being a lot clearer what you're trying to achieve, we can't really help you.

In general, though, if we're not talking about loading content dynamically, it's better to show/hide elements than to insert them at runtime. Moreover, it allows you to associate all your onClick actions all at once when the page is loaded, rather than having to add those at runtime, which is (1) fucking ugly coding, and (2) slow.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 15 2018 00:18 GMT
#18895
Okay, thank you. I've always steered away from javascript as much as I can, but I've decided to try to use it more for better performance for the user. So I'm kind of stumbling my way through it as I figure out what I'm doing. I was able to get it to work using your suggestion by hiding the divs and only showing the one currently selected. Appreciate the help, everyone!
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2018-02-15 02:18:41
February 15 2018 02:11 GMT
#18896
On February 15 2018 02:32 spinesheath wrote:
I compared performance of ms, gcc and intel compiled code for a molecular dynamics simulation as part of my bachelor's thesis. The software ran on the lrz cluster in munich. Obviously I wasn't very concerned with other aspects, but for performance, it was a rather clear intel > ms > gcc.

Also intel's performance analysis tools were awesome.

Today I would take llvm clang over gcc. Way faster, and much nicer for analysis tools on account of not completely fucking with the AST.

I think, though I haven't checked recently, that clang is also faster than icc now.
Who after all is today speaking about the destruction of the Armenians?
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2018-02-15 10:47:26
February 15 2018 10:33 GMT
#18897
2017 end of year test at phoronix shows gcc producing generally faster binaries than clang, but compiling slightly slower. i would like to see the compilation of some larger project though, like chromium or firefox (those were the ones that took the longest to compile when i was running gentoo). compilation time is medium important, but the test doesn't show a severe difference, and in practice i have seen long compilation times be mostly a result of code structure (library includes, dependencies, project structure (one binary vs ten binaries), template instantiations, project settings) and bad IDE habits.

in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.

my grief with the microsoft compiler has been crashing and bad error reporting, stone-age level in terms development of the language (relative to gcc / clang), slowness of bugfixing. they are supposed to be getting better and i am optimistic, it's not as awful as it used to be a one / two years ago.

i remember one of their updates breaking alias templates (std::enable_if_t<T> vs typename std::enable_if<T>::type), with the compiler all of a sudden just dying mid-compilation with the diagnostic 'compiler crashed'. i had to use the elimination method on the entire project to find out what was causing the error.

i also remember how when a typename gets "too long" and is mangled, if the compiler got a linker error involving this symbol, it would print some garbled numbers and letters instead of the symbol-name, inviting you to play the guessing game.

this will take a long time to forget, but getting std::variant will help (boost::variant is stone-age at compile-time, but fast at run-time).
conspired against by a confederacy of dunces.
ShoCkeyy
Profile Blog Joined July 2008
7815 Posts
February 15 2018 20:23 GMT
#18898
Anybody that works with Angular2 can you PM me? I need help with a dialog :/
Life?
Manit0u
Profile Blog Joined August 2004
Poland17679 Posts
February 16 2018 09:43 GMT
#18899
Fun fact: if you send this sequence of chars

U+0C1C U+0C4D U+0C1E U+200C U+0C3E

to any user using OSX/iOS it will crash the app that tried to display it (sometimes even creating the loop of death). Twitter, GMail, WhatsApp, Outlook, trying to display it in Safari etc.

There's a problem with parsing some unicode in Apple products.
Time is precious. Waste it wisely.
Excludos
Profile Blog Joined April 2010
Norway8233 Posts
Last Edited: 2018-02-16 10:22:08
February 16 2018 10:20 GMT
#18900
I'm not sure if this is the right place to vent, but maybe you could take it as a cautionary tale of why you should ALWAYS ALWAYS ALWAYS make your program modular.

So the place I work at is a bit weird in that we don't have proper project leaders. So I was told a month ago to start working on something, and have been hammering on the keyboard since then.

Then, quite randomly, I'm told that someone else have been told to work on the exact same thing. I go talk to him, and by a random stroke of luck, we've each completed different parts of the project, so together we actually have a working product. All I need to do now is merge my code into his. I take a look at it, and it's a fucking disaster! Everything is ingrained into itself. I can't change a single variable without ruining something in a completely different class. I have been struggling for hours and literally can not find a single way to use any of my code into his or vice versa. He's also completely forgotten to take into account how the user is suppose to interact with his system.

At this rate, I'm not sure what is faster: Continue struggling with this merge or just throw out his part of the code completely. I'm fucking pissed.
Prev 1 943 944 945 946 947 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 6h 9m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 257
Ketroc 1
StarCraft: Brood War
Sea 5848
GuemChi 1896
Artosis 731
Moletrap 8
Dota 2
monkeys_forever600
NeuroSwarm89
League of Legends
JimRising 678
Counter-Strike
Fnx 2247
taco 737
Super Smash Bros
hungrybox2039
Mew2King20
Heroes of the Storm
Khaldor179
Other Games
summit1g15654
C9.Mang0426
Maynarde176
JuggernautJason27
Organizations
Other Games
gamesdonequick920
Counter-Strike
PGL121
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Hupsaiya 113
• davetesta52
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift4149
• Rush630
Upcoming Events
Replay Cast
6h 9m
Wardi Open
9h 9m
Monday Night Weeklies
14h 9m
Replay Cast
21h 9m
Replay Cast
2 days
Replay Cast
2 days
The PondCast
3 days
KCM Race Survival
3 days
Replay Cast
3 days
Ultimate Battle
4 days
Light vs ZerO
[ Show More ]
Replay Cast
4 days
CranKy Ducklings
5 days
Replay Cast
5 days
Sparkling Tuna Cup
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Acropolis #4 - TS5
PiG Sty Festival 7.0
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
Spring Cup 2026
WardiTV Winter 2026
Nations Cup 2026
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025

Upcoming

ASL Season 21: Qualifier #1
ASL Season 21: Qualifier #2
ASL Season 21
Acropolis #4 - TS6
Acropolis #4
IPSL Spring 2026
CSLAN 4
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
NationLESS Cup
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.