|
The problem is that you've attached your event handler to all the matching elements that exist when that line runs, not to any that may exist in the future. What you need to do is attach the event handler to the document body and look at the classname there. I think jQuery has a syntax just for this http://api.jquery.com/on/
|
# ? May 15, 2017 22:21 |
|
|
# ? May 16, 2024 23:43 |
|
100 degrees Calcium posted:I wish I could say that was it, but this was actually my failure in re-typing the code when I should have copied-pasted. I don't even know why I did that. The post above me is correct, but here's a Pen proving it out: https://codepen.io/anon/pen/KmejWm You need to use $(document).on() to handle changes to the DOM like adding an input and maintaining live functionality. edit: shows how long ago I picked up jQuery. That article is from 2015 and I swear the previous method was to always attach to the document and then label the target as the second argument before entering an anonymous function. Video Nasty fucked around with this message at 01:59 on May 16, 2017 |
# ? May 16, 2017 00:25 |
|
Awesome. This was exactly the trick. Thank you all so much.
|
# ? May 16, 2017 00:36 |
|
You don't have to attach it to document, you can just attach it to the parent container. https://learn.jquery.com/events/event-delegation/
|
# ? May 16, 2017 01:24 |
|
poo poo. I'm embarrassed to have messed up something so basic, but I'm learning a lot of good poo poo here.
|
# ? May 16, 2017 01:43 |
|
My least favorite JavaScript "typo" is when something wants you to make a variable either camel case or dash case depending on the context. So even though your JavaScript and your HTML have the same variable name, it's not correct and acts like your variable doesn't even exist.
|
# ? May 16, 2017 03:03 |
|
afaik the plain JS way of doing $(document).on('change', selector, callback) can be done with matches,code:
code:
|
# ? May 16, 2017 09:24 |
|
Need help wrapping my head around promises. I need to make 3 api calls, and then do stuff to the results. I need wait until all three calls have returned. Currently what I have working is a total mess of cascading callbacks and I want to fix it. Using Node and request. Any links, or a quick run down?
|
# ? May 16, 2017 18:41 |
|
I recommend this article for in-depth understanding of promises: http://www.mattgreer.org/articles/promises-in-wicked-detail/ MDN also has a good explanation without getting too detailed.
|
# ? May 16, 2017 18:46 |
|
The link from Video Nasty is a REALLY good resource. This blog post is also really helpful for exploring the nuances and pitfalls that people run into in the wild: https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html
|
# ? May 16, 2017 18:51 |
|
The Fool posted:Need help wrapping my head around promises. Assuming your requests thing returns a Promise: code:
|
# ? May 16, 2017 18:55 |
|
The Fool posted:Need help wrapping my head around promises. Quick answer is, if you are using ES6 promises, is to use Promise.all([p1, p2, p3]).then( (allThreeResponsesArray) => { // do stuff to results } );, where p1 p2 and p3 are your API calls. Edit: bah, beaten.
|
# ? May 16, 2017 18:57 |
|
Based on what I've read, I have this working code: code:
code:
However, I'm just getting timeouts when testing with the promise. This is in and Azure functions app, for what it's worth. Am I making a stupid mistake, or is something else going on? edit: it times out because context.done() is never being called, which means .then() is never being called. which means? The Fool fucked around with this message at 23:07 on May 16, 2017 |
# ? May 16, 2017 22:56 |
|
The Fool posted:
nevermind me, this is patently stupid. Video Nasty fucked around with this message at 23:16 on May 16, 2017 |
# ? May 16, 2017 23:13 |
|
Video Nasty posted:You weren't using a Promise for your then call. I was under the impression that 'request-promise-native' did that for me?
|
# ? May 16, 2017 23:16 |
|
The Fool posted:I was under the impression that 'request-promise-native' did that for me? Hrm, maybe it isn't wrong. npm shows that you're clearly still supposed to call Promise to resolve before chaining the next function step. Not certain if this is the same package? https://www.npmjs.com/package/react-promise e: Either way, you need to govern the state of the promise resolution to delegate what fires next, so I do think you should wrap it in a Promise call.
|
# ? May 16, 2017 23:19 |
|
Video Nasty posted:Hrm, maybe it isn't wrong. Going to mess with it, but the examples linked from https://www.npmjs.com/package/request-promise-native don't do any wrapping.
|
# ? May 16, 2017 23:25 |
|
The Fool posted:Going to mess with it, but the examples linked from https://www.npmjs.com/package/request-promise-native don't do any wrapping. You're absolutely right. Ignore me, I looked up the wrong information.
|
# ? May 16, 2017 23:28 |
|
Continuing my saga: code:
idkwtf edit: this is with the normal requestjs module
|
# ? May 17, 2017 00:20 |
|
The Fool posted:Continuing my saga: That's not how Promises work. If you're using request (as in not rp) your promise code should look like this code:
p1 then becomes a Promise and you can either chain it with then() and catch() or else pass it to Promise.all() to coordinate request completion. Do more reading about Promises before you try to get around it by using Promise-based implementations without understanding what it's doing under the hood.
|
# ? May 17, 2017 00:31 |
|
Blinkz0rz posted:That's not how Promises work. I haven't been able to get rp to work either. quote:p1 then becomes a Promise and you can either chain it with then() and catch() or else pass it to Promise.all() to coordinate request completion. I get that. I've read a million examples of this, and I should have been able to just use rp to do this: code:
Same thing happens if I try to do this with only one API call. eg: rp(options).then(function(results) {}); quote:Do more reading about Promises before you try to get around it by using Promise-based implementations without understanding what it's doing under the hood. Thanks dad. edit: vvv- ha, yeah, just a typo for that post The Fool fucked around with this message at 01:08 on May 17, 2017 |
# ? May 17, 2017 00:52 |
|
The Fool posted:
I'm guessing this is just an error made while posting your code, but just in case: you're missing a closing bracket in Promise.all([p1,p2,p3)
|
# ? May 17, 2017 00:59 |
|
The Fool posted:then using request-promise-native: If you're not getting a 'then is not a function' error then you're probably not handling some exception that's being thrown. Try either a code:
code:
|
# ? May 17, 2017 01:07 |
|
Just having .catch() present solved my timeout problem on the single API call test. It's not even getting called. Let's see if it works with Promise.all() edit: all works now. Using bluebird instead of native promises because that's what I had it set to when the tests started working. Thanks for everyone's help, would have taken way longer and been way more frustrating without it The Fool fucked around with this message at 01:53 on May 17, 2017 |
# ? May 17, 2017 01:33 |
|
I have a table row click event listeners that are driving me crazy. If I click the text inside the row's columns, the event does not trigger first click. It will the 2nd. I thought it might have to do with event bubbling or capturing, but I tried capturing with no luck. I'm afraid it might have to do something Polymer messing with things. Any other ideas of what could cause this? Does it have to do something with focus? e: I don't know what I'm talking about with "focus". You can only focus on input elements. LP0 ON FIRE fucked around with this message at 21:45 on May 17, 2017 |
# ? May 17, 2017 21:17 |
|
It might be polymer. This very simple fiddle works on every click from the start: https://jsfiddle.net/834mxrn8/
|
# ? May 17, 2017 22:22 |
|
necrotic posted:It might be polymer. This very simple fiddle works on every click from the start: https://jsfiddle.net/834mxrn8/ I tried the same thing in jsfiddle. I also attempted to capture any target clicked first click on the text inside the table row on the original page I'm having the problem. It logs nothing first click. code:
|
# ? May 18, 2017 15:16 |
|
LP0 ON FIRE posted:I tried the same thing in jsfiddle. I also attempted to capture any target clicked first click on the text inside the table row on the original page I'm having the problem. It logs nothing first click. Something would have to stop the event from propagating. Here's how to find what's doing it http://stackoverflow.com/a/10213800/301807
|
# ? May 18, 2017 15:34 |
|
Hey dudes. I'm trying to make an NPM package from some code that works around a limitation of another package; posted about this earlier. Would anyone mind skimming my build files (webpack.cfg and package.json) to see if there's anything I'm missing? The component works properly when placing the src index.tsx file in with my other files and importing, but webpack can't find my module when trying to import through npm_modules.
Dominoes fucked around with this message at 17:52 on May 18, 2017 |
# ? May 18, 2017 17:38 |
|
You have to publish the compiled code I believe. Node/NPM don't know anything about typescript. http://stackoverflow.com/questions/30928253/writing-npm-modules-in-typescript edit: Just looked at your package.json, looks like you are publishing that way. Shoulda looked first, sorry.
|
# ? May 18, 2017 18:01 |
|
Munkeymon posted:Something would have to stop the event from propagating. Here's how to find what's doing it http://stackoverflow.com/a/10213800/301807 Thanks for the info. I found that a click event is never registered the first time if the user clicks the text in the td as explained above, but a mouseup event is made. I figured out a work around by checking if the event.target of the mouseup event is a td and the parent has a data-dialog attribute for the popup that is supposed to get triggered. Add this fix to your coding horrors: code:
|
# ? May 18, 2017 18:01 |
|
What's the simplest way to disable and "grey out" a button while a process occurs? I'm cobbling together a rudimentary frontend for an API as a demo and for some reason none of the things I've googled for seem to work. The rest of my awful code is working about as well as can be expected. I just know as soon as I show someone the first thing they'll do is hammer the button dozens of times while they wait for a large GET response. As an example, here's one of my functions:code:
PierreTheMime fucked around with this message at 20:25 on May 18, 2017 |
# ? May 18, 2017 20:21 |
|
Your code for disabling and enabling the button is fine. I suspect your xmlhttp request is acting asynchronously. You could place a console.log() statement at your button disable, at your button re-enable, and at the end of (but inside) your request function. If the re-enable one fires before the request one, this is your problem.
Dominoes fucked around with this message at 20:36 on May 18, 2017 |
# ? May 18, 2017 20:33 |
|
PierreTheMime posted:What's the simplest way to disable and "grey out" a button while a process occurs? I'm cobbling together a rudimentary frontend for an API as a demo and for some reason none of the things I've googled for seem to work. The rest of my awful code is working about as well as can be expected. I just know as soon as I show someone the first thing they'll do is hammer the button dozens of times while they wait for a large GET response. As an example, here's one of my functions: You need to put your getinfo.disabled = false; line inside the onreadystatechange method if you want it to enable the button depending on the AJAX call. As it stands now it's going to disable, start the async ajax call and then keep on executing your code, which the next line is getinfo.disabled = false. ddiddles fucked around with this message at 20:41 on May 18, 2017 |
# ? May 18, 2017 20:38 |
|
ddiddles posted:You need to put your getinfo.disabled = false; line inside the onreadystatechange method if you want it to enable the button depending on the AJAX call. As it stands now it's going to disable, start the async ajax call and then keep on executing your code, which the next line is getinfo.disabled = false. That did it, thanks!
|
# ? May 18, 2017 20:46 |
|
Here's a question at the intersection of Typescript and Immutable.js, in case anybody is crazy enough to know the answer. I have a Record-extending class Tom, with the attributes jones, ofFinland, and andJerry. I get in an arbitrary string, whichTom. How do I define a Typescript type guard function such that this: code:
|
# ? May 19, 2017 02:10 |
|
Roadie posted:Here's a question at the intersection of Typescript and Immutable.js, in case anybody is crazy enough to know the answer. Are jones, ofFinland, and andJerry all the same type?
|
# ? May 19, 2017 14:00 |
|
I think you can do tomInstance.has(<keyof Tom>whichTom)
|
# ? May 19, 2017 15:04 |
|
Is there a generally accepted way to do single signon/LDAP authentication for single-page apps? I basically want to valid that the user is a valid employee and pass their user id in my REST request for logging afterward. I'm building a super-simple site for some reporting features and I'd like to keep it all in one file if possible, but if it must use other stuff I guess I can get to learning that as well.
|
# ? May 19, 2017 16:22 |
|
|
# ? May 16, 2024 23:43 |
|
PierreTheMime posted:Is there a generally accepted way to do single signon/LDAP authentication for single-page apps? I basically want to valid that the user is a valid employee and pass their user id in my REST request for logging afterward. I'm building a super-simple site for some reporting features and I'd like to keep it all in one file if possible, but if it must use other stuff I guess I can get to learning that as well. If you want to keep it extremely bare-bones, you can just do HTTP Basic against an LDAP backend. Nginx or Apache or whatever will give this to you out of the box as a reverse proxy.
|
# ? May 19, 2017 16:45 |