Home Bootstrap remote Modal doesn't update content after first run
Reply: 0

Bootstrap remote Modal doesn't update content after first run

user1997 Published in March 24, 2018, 12:45 am

It comes javaScript and jQuery are beeing a big challenge for me. Like it's not enough I've started to use ajax to get over my problem - which is:

I've got some empty tables on my page. Each cell of a table has got its own id. A php-script is parsing a .xlsx file and puts the right link to the cell of my html table through javaScript code like:

document.getElementById("cellNrXY").innerHTML = "<a href=".../remoteContent.php">someLink</a>";

If the link is clicked, then a Modal (Bootstrap) appears and loads the remote content (which is different depending on the clicked link).

My problem was that the remote content was cached in modal, so it worked only on first run. After closing the modal and choosing another link the previous modal appeared und didn't change to the new remote content. I've read a lot solutions here that are based on:


but had no luck with it. After some trying with different solutions one worked properly. The only problem was: when I've clicked the second time on some other link, the modal opened up with previous content and it took some seconds for the modal beeing updated. This is why I wanted to show a rotating element while the new modal content is beeing loaded. Somewhere here I've read a solution tu use ajax for this, which I've added "on luck" and ... it worked:

$("#myModal").on("show.bs.modal", function(e) {
beforeSend: function() { $('#myModal')
                        .html('<div class="rotatingElement"></div>')
                        .show(); },
complete: function() { $('#myModal').html.hide(); }
var link = $(e.relatedTarget);      

The only thing is - I've no idea why this is working. Is there any chance that somebody here explain the functionality of this code to me?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304771 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO