I had some similar problems with modals in Joomla.
Unfortunately I posted my question on the normal stackoverflow.
But maybe it can still help some people.
https://stackoverflow.com/questions/33481030/joomla-3-use-form-in-modal
I switched from jFroms to Visforms because jForms loads mootools and that does not work properly with the rest...
It's a dynamic modal with Bootstrap and also I have a new version with Uikit.
Code
This is the version with Uikit. Just because it is more elegant.
The basic modal structure sits at the top of the index file:
<div id="modal" class="uk-modal">
<div class="uk-modal-dialog">
<div class="uk-modal-header">
<a class="uk-modal-close uk-close"></a>
</div>
<div class="uk-modal-content">
...
</div>
</div>
</div>
The trigger links look like this:
<a href="some internal link" class="modal-trigger">Open modal</a>
Script:
var $modalTrigger = $(".modal-trigger");
var $modal = $("#modal");
var $modalContent = $(".uk-modal-content");
var spinner = '<div class="uk-modal-spinner"></div>';
if( $modalTrigger.attr("href") ){
$modalTrigger.attr("data-uk-modal", "{target:'#modal'}");
};
$modalTrigger.click(function() {
$modalContent.append(spinner);
$modalContent.load( $(this).attr("href") );
});
$modal.on({
'hide.uk.modal': function(){
$modalContent.empty();
}
});
On every link with the .modal-trigger
class it adds the needed Uikit data attributes data-uk-modal", "{target:'#modal'}
, grabs the link and loads it into the .uk-modal-content
.
All content will be removed after closing the modal in order to load new content.