I’m total beginner in js and JQuery and have to complete such task:
I have to open new window with some document print preview. It is not a problem for single document, but there’s a need to print more than one document. I was trying to do this like that:
var win = window.open("", "test", "width=700,height=600");
$(win.document).ready(function(){
$(win.document).contents().load("here_my_action_with_changing_id");
})
});
but it only loads first document and I don’t have any idea how to load one after another.
Also, it seems not to work on IE properly.
To start with, you need to change this
$(win.document).readyto$(document).ready– or indeed$(function() { ... });which is a shorter version of writing it.Same goes for the load call, but you probably want to change the binding here so that on link clicks of a specific type, the window.open is called – rather than on the document ready event.
I would also suggest you create a single link for each document you wish to print – trying to print multiple documents from a single link would require quite a lot of effort and be fairly tricky to develop and synchronise
What you could then do is use the jQuery
indexAPI to find the index of the<a>tag within the list of<a>tags, in order to generate an id to pass to your load call, so it knows which piece of content to load and subsequently print based on the link that was clicked.