From 0d16a8beb7a0bdb6213058774c879c226eca663a Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 9 Aug 2016 12:30:40 +0200 Subject: [PATCH] Fixed bug where Listener was not placed if the row was not displayed (BrowseWarningPaste) --- .../templates/important_paste_by_module.html | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/var/www/templates/important_paste_by_module.html b/var/www/templates/important_paste_by_module.html index 640e20a8..164ed800 100644 --- a/var/www/templates/important_paste_by_module.html +++ b/var/www/templates/important_paste_by_module.html @@ -41,8 +41,7 @@ $(document).ready(function(){ var start_index = 0; // On click, get html content from url and update the corresponding modal - $("[data-toggle='modal']").on("click", function (event) { - console.log('hi'); + $("[data-toggle='modal']").on("click.openmodal", function (event) { event.preventDefault(); var modal=$(this); var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num'); @@ -108,5 +107,44 @@ $(document).ready(function(){ new_content.show('fast'); $("#load-more-button").hide(); } + + + + // Use to bind the button with the new displayed data + // (The bind do not happens if the dataTable is in tabs and the clicked data is in another page) + $('#myTable').on( 'draw.dt', function () { + // On click, get html content from url and update the corresponding modal + $("[data-toggle='modal']").unbind('click.openmodal').on("click.openmodal", function (event) { + console.log('hi'); + event.preventDefault(); + var modal=$(this); + var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num'); + $.get(url, function (data) { + $("#mymodalbody").html(data); + var button = $(''); + button.tooltip(); + $("#mymodalbody").children(".panel-default").append(button); + + $("#button_show_path").attr('href', $(modal).attr('data-url')); + $("#button_show_path").show('fast'); + $("#loading-gif-modal").css("visibility", "hidden"); // Hide the loading GIF + if ($("[data-initsize]").attr('data-initsize') < char_to_display) { // All the content is displayed + nothing_to_display(); + } + // On click, donwload all paste's content + $("#load-more-button").on("click", function (event) { + if (complete_paste == null) { //Donwload only once + $.get("{{ url_for('getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){ + complete_paste = data; + update_preview(); + }); + } else { + update_preview(); + } + }); + }); + }); + } ); +