Facebook Like Button on a Dynamically Changed Modal

1

I have an application using the Facebook JavaScript SDK, there is a simple modal that has its content dynamically created. It's important to note that the code is working properly, except for the Like button on facebook.

Modal part in HTML code:

<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content -->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>

            </div>
            <div class="modal-body" id="modal-body"></div>
            <div class="modal-footer" id="modal-footer"></div>
        </div>
        <!-- / Modal content -->
    </div>
</div>
<!-- / Modal -->

Javascript:

       function showModal(aux) {
            var title;
            var message;
            var footer;

            switch (aux) {
                    (...)
                    case (2): // Like
                        title = 'Erro';
                        message = '<p>Você ainda não curte nossa página, clique em "Like" e depois em continuar.<div class="fb-like" data-href="ENDERECO-PAGINA" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div></p>';
                        footer = '<button type="button" class="btn btn-default" data-dismiss="modal" onClick="checkLike()">Continuar</button><button type="button" class="btn btn-default" data-dismiss="modal" onClick="showModal(4)">Cancelar</button>';
                        break;                                
                        (...)
            }
            $('#myModal').find('.modal-header').html(title);
            $('#myModal').find('.modal-body').html(message);
            $('#myModal').find('.modal-footer').html(footer);

            $('#myModal').modal();
        }

The button does not appear in the modal. Any suggestions?

    
asked by anonymous 26.10.2015 / 00:32

1 answer

1

Issue resolved by changing part of the code for the code below:

message = '<p>Você ainda não curte nossa página, clique em "Like" e depois em continuar.<br/><iframe src="http://www.facebook.com/plugins/like.php?href=ENDERECO-PAGINA"scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe></p>';

Better solutions are welcome!

    
26.10.2015 / 00:40