Link to home
Start Free TrialLog in
Avatar of Stephen Forlance
Stephen Forlance

asked on

Boostrap modal not loading ajax

Hello,
Im just trying to get to grips with using Modals and Bootstrap, can anyone look at :

http://dnx.org/eno/

And tell me why the button launches a modal, but the content is not replace with ajax content (from content.html )?


Thanks,
Avatar of Jim Riddles
Jim Riddles
Flag of United States of America image

It looks you are wrapping your event handler before the element is loaded in the DOM.  The easiest fix is to include your script at the end of your document.
Avatar of Stephen Forlance
Stephen Forlance

ASKER

Thank you!

Bit of a strange one, but the original code for stacking modals comes from:

https://codepen.io/maouida/pen/NPGaaN

On the original it animates the stacked modal, pushing it to the side and back. The same used to happen with my code, but with AJAX working its now stopped, any ideas?
what is wrong with your demo?
I can see 4 modals with different contents on each...
On the code pen demo (
https://codepen.io/maouida/pen/NPGaaN ) when a new modal is launched, the previous one is animated away, moving to the side and back. However, on my version ( http://dnx.org/eno/ ) , it doesnt happen.
re arrange js files

first jQuery
then modal library
then yours
+ put your js in DOM ready


$("#test-modal").on("show.bs.modal", function(e) {
    var link = $(e.relatedTarget);
    $(this).find(".modal-body").load(link.attr("href"));
});

Open in new window


>>>

<script type="text/javascript">
$(function(){

$("#test-modal").on("show.bs.modal", function(e) {
    var link = $(e.relatedTarget);
    $(this).find(".modal-body").load(link.attr("href"));
});

});
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial