0

I have a Django App that, from a template feed.html calls different templates for different elements in the data base. The idea is to use a JavaScript script to visualize each one of these elements, the problem is that it just show the last one of them (the last element in this page).

The script is this one:

function showPiece(targ, piece){
    window.onload = function(){
        Lily.ready({
                target: targ,  // target div id
                file: 'files',  // file input id
                path: '../../static/js/src', // path to source directory from current html file
        });
    };


    window.onload = function(){
            var madeleine = new Madeleine({
                target: targ, // target div id
                data: piece,
                path: '../../static/js/src', // path to source directory from current html file
            });
    };
};

I am calling the script from the feed.html file.

<script type="text/javascript" charset="utf-8">
  var url_objetivo = '{{ piece.file.url }}'
  var id_objetivo = "id-" + {{ piece.id}}
  showPiece(id_objetivo, url_objetivo)
</script>

How can I force it to display the information for every element?

Manuel Gijón
  • 118
  • 1
  • 10
  • checkout [this stack overflow post talking exactly about this type of problem:](https://stackoverflow.com/questions/16683176/add-two-functions-to-window-onload). Basically you can only have one window.onload or you need to tweek your code a bit. – ha-neul Nov 25 '19 at 16:38
  • I've tried but it does not work – Manuel Gijón Nov 26 '19 at 09:56

0 Answers0