coolio83000 coolio83000 - 3 months ago 19
HTML Question

use the function Load jquery

I want to load different div with different link in a unic modal. My problem is when I click in the link modalcookieslink or modaloffreslink it works fine. But when I close my modal and want to try if the second works, I have #cookies and #offres content in my modal in the same time.

I think the problem is that my page doesn't refresh when I close the modal ?

HERE IS HOW I CALL MY DIV WITH THE LOAD FUNCTION

$("#modalcookieslink").click(function(){
$('#modalcookies').load('modif.html #cookies');
});

$("#modaloffreslink").click(function(){
$('#modaloffres').load('modif.html #offres');
});

Answer

So remove the content from the other element

$("#modalcookieslink").click(function(){
    $('#modaloffres').html("");
    $('#modalcookies').load('modif.html #cookies');
});

$("#modaloffreslink").click(function(){
    $('#modalcookies').html("");
    $('#modaloffres').load('modif.html #offres');
});

or if the modal has a close event, bind to it and clear the contents.