// Populate the modal div with the snippets view $("#snippets-modal").html("<%= escape_javascript( render "list", snippets: snippets, search: search, author: author, remote: true ) %>"); // Show the snippets modal $("#snippets-modal").foundation('reveal', 'open'); // Make the sorting and pagination links 'remote' so they do not navigate away. $('.snippets').on('click', 'th a, .pagination a', function () { $.getScript(this.href); return false; } ); initTogglers(); $('.insert-snippet').on('click', function (e) { var modal = $("#snippets-modal"); var snippetBody = $(this).parent().closest("tr").find(".body").html(); var targetInputSelector = $(modal).data("target"); var targetInputSelector = $(targetInputSelector)[0]; targetInputSelector.editor.insertHTML(snippetBody) $(modal).foundation('reveal', 'close'); } );