I want to open a popup using jQuery to display a selection of images. Images are wrapped in link tags in an unordered list. At some point, navigation will be added, so I don’t think the dialogue is suitable. Here is the code that I still have:
Main page:
<script> $('.ImageManager').click(function (event) { event.preventDefault(); window.open($(this).attr("href"), "popupWindow", "width=600, height=400, scrollbars=yes"); }); </script> <a href="/image-manager" class="ImageManager">Add Image</a><br /> <ul id="imagelist"> </ul>
Pop-up window:
<script> $(function() { $(".addimage").click(function() { $("#imagelist", opener.document).append("<li></li>"); return false; }); }); </script> <ul> % for image in images: <li><a href="" class="addimage"><img src="/static/images/{{ image }}" alt="" /></a></li> % end </ul>
The first problem is that the popup does not open, it just opens the image manager in the current browser window. I have jQuery listed in the chapter section of both pages and it works with other jQuery code.
Secondly, I tried using simple Javascript to open the popup that worked, but I couldn’t get a click link to add the image file name to the open window, and the popup does not close afterwards.
If I can make the popup work, how do I pass the {{image}} variable (Python Bottle template variable) passed when I clicked the image in the popup?
user521836
source share