Skip to content

Instantly share code, notes, and snippets.

@umidjons
Last active October 2, 2019 07:50
Show Gist options
  • Save umidjons/5956807 to your computer and use it in GitHub Desktop.
Save umidjons/5956807 to your computer and use it in GitHub Desktop.
Bitrix Dialog box example more on that here: http://alexvaleev.ru/popup-window-bitrix/
<?
CUtil::InitJSCore( array( 'window' ) ); // load Bitrix's window library
$APPLICATION->AddHeadScript( '/js/jquery.min.js' ); // load jQuery
?>
<? ob_start(); // start capturing HTML output ?>
<p>Some HTML content...</p>
<?
$content = ob_get_contents(); // save output info variable
$content = str_replace( array( "\n", "\r" ), '', $content ); // remove EOL-s - content: attribute of the BX.CDialog() requires that!
ob_end_clean(); // clean buffer
?>
<a class="show-window" href="">Open window</a>
<script type="text/javascript">
jQuery(document).ready(function ($) {
var Dialog = new BX.CDialog({
title: "Window Title",
head: "Content before main content",
content: '<?= $content ?>',
icon: 'head-block',
resizable: false,
draggable: true,
height: 400,
width: 600,
buttons: [BX.CDialog.btnCancel]
});
$('.show-window').click(function (__event) {
Dialog.Show();
__event.preventDefault();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment