Last active
October 2, 2019 07:50
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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