Build a bootstrap modal dialog only with javascript ? possible?

Hi folks,

starting from some bootstrap code to build a modal dialog,

<div class="modal" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

how can I build this using only javascript ?
using document.createElement ?
what is the best easy way to do this ?

thanks.

I read this earlier this week:

You can see his code and get some ideas:

You’re on the right track with createElement. :slight_smile:
https://www.php.net/manual/en/book.dom.php

I know that’s PHP, but JS should be very similar.

the end idea is to use it with xojo executejavascript in fact…

You probably found your solution in the meantime, otherwise this is a good starting point:
https://www.w3schools.com/howto/howto_css_modals.asp

1 Like

thanks? it is to use it from a xojo web app 2
and it seems not possible. at least to get an return value like “yes” or “no” ?
but this link is a good start.

If you add the bootstrap modal code to the page, you can use the on click function to send the click yes/no/other data back. With JS you could run some JS or pass the data back to Xojo somehow. In php, I’d call a js ajax function that then does the php stuff. Xojo process would be similar.

span.onclick = function() {
  modal.style.display = "none";
}

yeah without a web sdk control backing this you have nothing to “send the event TO”
so it wont go anywhere

Can you use the new Xojo ExecuteJavascript thing in Web 2.0? I meant “Xojo.TriggerServerEvent”

I understand this is only available from a websdkuicontrol ?

Sorry. This is another reason I use PHP instead Xojo. Xojo has too many issues.

1 Like