Change Content within a modal

1

How can I load a modal and in that modal have a button that when I click, swap the content for another page of this modal that is already open, and that when closing, go back to the previous content. I'm using the materialize front-end framework.

I'm having trouble working on js where I change the contents of the initial modal through another page, I can change the content for a text, but not open another page inside it.

    
asked by anonymous 28.12.2016 / 03:00

1 answer

1

Hello.

You need to load the data dynamically on the same page or from another. No need for iframe. But it will load the page html, or even a div or other specific tag using a very simple jQuery (requires basic knowledge). But this is also possible using angular (requires intermediate knowledge).

In jQuery I use this code for this:

$('#MytargetDiv').load('https://www.example.org/anyPage.html #MytargetContent', function() {
// escreva suas funções ou ações aqui
// você pode alterar, ocultar ou exibir o conteúdo recebido como no exemplo abaixo
$('p.summary').hide(); // ou
$('div img.thumb').remove(); // se o carregamento for bem sucedido estas funções ou ações serão executadas. isso permite infinitas possibilidades.
});

If you need or want to use the full content you can use it this way.

$('.Class4TargetDiv').load('https://www.example.org #TargetDivWithContent');

or

$('#MyTargetDiv').load('https://www.example.org .TargetDivWithContent');

Remembering that to identify the element you want to load you can identify it by Id (#elementid) or by a CSS class (.anyclass).

Note: You must apply or call this code in the event of the link or button you will use to trigger the content change.

I hope it's useful.

    
28.12.2016 / 16:33