barryvdh / laravel-elfinder

elFinder bundle for Laravel
745 stars 171 forks source link

How add bootstrap modal #194

Open jsonpreet opened 7 years ago

jsonpreet commented 7 years ago

Hi,

I added elfinder iframe in bootstrap modal but now i have issue close modal when file is selected. I got error message

Error in `getFileCallback`.
jQuery(...).modal.hide is not a function

I changed in code closing function

<script type="text/javascript">
        $(document).ready(function () {
            var elf = $('#elfinder').elfinder({
                // set your elFinder options here
                <?php if($locale){ ?>
                    lang: '<?= $locale ?>', // locale
                <?php } ?>
                customData: { 
                    _token: '<?= csrf_token() ?>'
                },
                url: '<?= route("elfinder.connector") ?>',  // connector URL
                soundPath: '<?= asset($dir.'/sounds') ?>',
                dialog: {width: 900, modal: true, title: 'Select a file'},
                resizable: false,
                commandsOptions: {
                    getfile: {
                        oncomplete: 'destroy'
                    }
                },
                getFileCallback: function (file) {
                    window.parent.processSelectedFile(file.path, '<?= $input_id?>');
                    jQuery('#elfinderModal').modal.hide();
                }
            }).elfinder('instance');
        });
    </script>
hungnm144 commented 7 years ago

Try to change jQuery('#elfinderModal').modal.hide(); to parent.jQuery('#elfinderModal').modal.hide();

arturmamedov commented 6 years ago

Or use new window, its a good practice https://goo.gl/4YyP3J