HubSpot / vex

A modern dialog library which is highly configurable and easy to style. #hubspot-open-source
http://github.hubspot.com/vex/docs/welcome
MIT License
6.92k stars 491 forks source link

Is it possible to load Dynamic Content from Ajax? #204

Closed ajaykr089 closed 7 years ago

ajaykr089 commented 7 years ago

Hey,

I was trying to load some dynamic content using the "vex.dialogs" method, but right now i have to make separate ajax request for the content and then popup loads up, that is show some delay time opening the popup due to ajax request time, Is there any method in the library that can do the ajax job internally?

bbatliner commented 7 years ago

No, there is no way to do this with vex currently.

Purely hypothetical, but I think there could be a solution with providing a Promise to the message or input options, like so:

vex.dialog.open({
  message: fetch('/contentUrl').then(resp => resp.text())
})

And vex would be able to internally detect that the content is asynchronous, and be able to show a loading spinner or something.

Closing the issue because the answer is "no", but I'd love to hear your thoughts on the Promise idea.