andybeak
11/18/2015 - 2:43 PM

Open url (same domain) in modal

Open url (same domain) in modal

    <script>
        // requires jQuery and jQueryUI
        $(document).ready(function() {
            $( "#dialog" ).dialog({
                autoOpen: false
            });

            $('.modal-link').click( function(e) {
                e.preventDefault();
                var url = $(this).attr('href');
                var title = $(this).attr('title');
                $('#dialog').dialog('option', 'title', title);
                $.get( url, function(data) {
                    $('#dialog').html(data).dialog('open');
                });
            });
        });
    </script>
<div>
  Click <a href="/upload" class="modal-link" title="Upload your file">here</a> to upload an document.  
</div>

<div id="dialog"></div>