javascript - Return Input from Custom Popup -


i working on custom modal popup entity. when need text value user, make html element visible, need value enter in text field when press "enter" button.

the problem i'm trying doesn't seem have easy implementation. don't think it's possible without promises, , attempts far have not worked. ideas on possible solutions?

turns out managed myself. had assumed promise somehow end when reached end of code, not true: continue when resolve manually. therefore when set onclick of button possibility of resolving it, wait button pressed. see code sample below:

var modalpopup() = function() {   //display popup   document.getelementbyid("generalmodalbackground").style.display = "flex";    return new promise(function(resolve, reject) {     document.getelementbyid("generalsubmitbutton").onclick = function() {       //when clicked, resolve promise inputted value       let returnval = document.getelementbyid("generaltextfield").value;       resolve(returnval);     }   }); }  modalpopup().then(function(textneeded) {   //do stuff need }); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -