eldarion / eldarion-ajax

a library for adding declarative ajax functionality to your website
BSD 3-Clause "New" or "Revised" License
758 stars 153 forks source link

Add first class support for bootstrap modals #37

Open paltman opened 11 years ago

paltman commented 11 years ago

There was a partial attempt at this in #13 which I closed after suggesting a work around, but it would be nice to have the modals driven via declarative markup.

Use Cases

  1. Display a modal that is a server rendered content fragment that an a.ajax click fetches
  2. Close the modal on posting of a form rendered in the modal
  3. Display secondary content in the modal after posting a form that was rendered initially in the modal.

Cases 1 and 2 are fairly easy to solve (at least I am pretty sure), the case in number 3 is a bit tricky as we want to avoid the modal closing and reopening and want the modal to just replace the insides instead of flashing about on the screen. One approach would be to have secondary fragments that were just replaced and not the entire div.modal but that could get out of hand in managing a ton of different templates.

Open to ideas/suggestions on this.

Currently, I think the best work around there is for this is to load the modal fragment as hidden and have the following script fragment to remove excess backgrounds and show the modal (this seems to work for me for most cases but would like to alleviate the need of evening having to do this):

<script>
    $(".modal-backdrop").remove();
    $("#my-modal").modal("show");
</script>

where #my-modal is referencing the id you place your modal div to make it unique.

brycenesbitt commented 10 years ago

There's also a case 1.5 : redisplay a form that came back from the server with errors.

At times it's also desirable to have client side javascript validation of the form inputs, with the SUBMIT button disabled until the form validates (example: you must supply one of the following: email address or phone number).