Dynamic HTML inside SweetAlert
andreiculda opened this issue · 2 comments
andreiculda commented
When adding dynamic HTML like a bootstrap tablist with tables and other html components inside, the Sweet alert is not centered on the screen.
i declared html content as:
var htmlcontent = '<ul class="nav nav-pills" role="tablist">' +
'<li role="presentation" class="active"><a href="#POCInfo" data-toggle="tab">Details</a></li>' +
'<li role="presentation" >' +
'<a href="#Questionnaires" data-toggle="tab">' +
'<span class="label label-success"> ' + markers[z].QuestionnairesCount + '</span>' +
' Questionnaires' +
'</a>' +
'</li>' +
'<li role="presentation" class="disabled"><a href="#" >Orders</a></li>' +
'</ul>' + .......
and I called SweetAlert like this:
swal({
title: markers[z].Name + ' visit on ' + markers[z].VisitDate,
text: htmlcontent,
html: true
});
Do you have a solution for this or is there something i'm doing wrong?
andreiculda commented
codrut commented
Andrei, you have to dynamically update the margins of the alert also when you use dynamic width content inside the alert container.
After you generate the dynamic content, just calculate the width and set margin-left: -(newWidth)/2