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,
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,
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.
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?
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...
I can see 4 modals with different contents on each...
ASKER
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.
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
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"));
});
>>>
<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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.