Good day.
I am trying to implement a bootstrap modal window. Naryl code, respectively, I want to change the window in my own way. But to edit the HTML in the line, the creepiness is awkward:
$(document).ready(function() { $('a[data-confirm]').click(function(ev) { var href = $(this).attr('href'); if (!$('#dataConfirmModal').length) { // *** тут создается модальное окно $('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="dataConfirmLabel">Please Confirm</h3></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button><a class="btn btn-primary" id="dataConfirmOK">OK</a></div></div>'); } $('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm')); $('#dataConfirmOK').attr('href', href); $('#dataConfirmModal').modal({show:true}); return false; });}); I decided to create a separate class and submit the form to them:
public static function showModalConfirm() { ?> <div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"> ... </div> <?php } So:
$('body').append('<?= Template::showModalConfirm() ?>'); The problem is that the form is transmitted with all spaces and hyphenations. The script only works if the form is described in a string. (although this is better, although the syntax is highlighted) You can, of course, write a parser, but it looks like it will be a "bicycle".
What is normal practice in similar questions?