Pergunta

Tenho tentado, sem sucesso, adicionar uma quebra de linha a um modal de bootstrap DRY.

Aqui está meu código de modelo de hiperlink que envia a mensagem para o código de exibição modal:

<a href="{% url achievement_details_delete achievement_detail.id %}" delete-confirm="Are you sure you want to DELETE the selected record? <br /><br />This action will permanently remove the record.">Delete</a>

Aqui está meu código modal jquery bootstrap:

$(document).ready(function() {

    //START: Delete code.
    $('a[delete-confirm]').click(function(ev) {

        var href = $(this).attr('href');

        if (!$('#deleteConfirmModal').length) {

            $('body').append('<div id="deleteConfirmModal" class="modal modal-confirm-max-width" role="dialog" aria-labelledby="deleteConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button><h4 class="modal-title" id="deleteConfirmLabel">{% trans "Delete" %} - {{ resume_details_trans }}</h4></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>&nbsp;&nbsp;<a class="btn-u btn-u-red" id="deleteConfirmOK" onclick="showProgressAnimation();">{% trans "Delete" %}</a></div></div>');

        }

        $('#deleteConfirmModal').find('.modal-body').text($(this).attr('delete-confirm'));

        $('#deleteConfirmOK').attr('href', href);

        $('#deleteConfirmModal').modal({show:true});

        return false;

    });
    //FINISH: Delete code.
});
Foi útil?

Solução

Adicione isto ao botão para excluir o registro:

<a href="url"
   delete-confirm="Your Message Here!!<br /><br /><span class='confirm_delete_warning_red_bold'>You can even add in css to highlight specific text - Are you sure?</span>"
>
    Delete
</a>

E no seu código jquery altere o .text para .html.Text renderizará o texto e .html atuará como html e exibirá as quebras de linha e css na tag span.

 $('#deleteConfirmModal').find('.modal-body').html($(this).attr('delete-confirm'));

Isso funcionará para o seu código.Basta observar o uso de ' e " (marcas falantes simples e duplas).Não os misture.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top