Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing JQuery to open a popup window and print
    primarykey
    data
    text
    <p>A while back I created a lightbox plugin using jQuery that would load a url specified in a link into a lightbox. The code is really simple:</p> <pre><code>$('.readmore').each(function(i){ $(this).popup(); }); </code></pre> <p>and the link would look like this:</p> <pre><code>&lt;a class='readmore' href='view-details.php?Id=11'&gt;TJ Kirchner&lt;/a&gt; </code></pre> <p>The plugin could also accept arguments for width, height, a different url, and more data to pass through.</p> <p>The problem I'm facing right now is printing the lightbox. I set it up so that the lightbox has a print button at the top of the box. That link would open up a new window and print that window. This is all being controlled by the lightbox plugin. Here's what that code looks like:</p> <pre><code>$('.printBtn').bind('click',function() { var url = options.url + ( ( options.url.indexOf('?') &lt; 0 &amp;&amp; options.data != "" ) ? '?' : '&amp;' ) + options.data; var thePopup = window.open( url, "Member Listing", "menubar=0,location=0,height=700,width=700" ); thePopup.print(); }); </code></pre> <p>The problem is the script doesn't seem to be waiting until the window loads. It wants to print the moment the window appears. As a result, if I click "cancel" to the print dialog box, it'll popup again and again until the window loads. The first time I tried printing I got a blank page. That might be because the window didn't finish load.</p> <p>I need to find a way to alter the previous code block to wait until the window loads and then print. I feel like there should be an easy way to do this, but I haven't found it yet. Either that, or I need to find a better way to open a popup window and print from the lightbox script in the parent window, without alternating the webpage code in the popup window.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload