0

I'm using dropzone from https://www.dropzonejs.com to upload a single picture. I'm loading a html-page with the command .load of jquery like this:

$( "#showsettingsother" ).click(function() {
     $('#settingscontent').load('settingscompany.html', function() {
          Dropzone.autoDiscover = false;

          var myDropzone = new Dropzone($('.dropzone').get(0), {
            init: function() {                     
                   var me = this;

                  $.getJSON(webserverurl + '?sessionid=' + sessionkey + '&settings=true&company=checkCompanyPhotoExists', function( json ) {
                    if(json.STATUS == 'OK') {
                        var mockFile = { name: "Firmenlogo", dataURL: getcompanypicture, accepted: true };
                        me.createThumbnailFromUrl(mockFile, getcompanypicture);
                        me.files.push(mockFile);
                        me.emit('addedfile', mockFile);
                        me.emit('thumbnail', mockFile, getcompanypicture);
                        me.emit('complete', mockFile);
                    }
                  });
                },
                ... [shortened]
          }
        }
}

Inside settingscompany.html I've got this:

<form id="uploadCompanyPicture" action="" class="dropzone"></form>

Now I've got a menu like this:

<ul>
    <li id="settingscompany"><a id="showsettingscompany" href="#">Company settings</a></li>
    <li id="othersettings"><a id="showsettingsother" href="#">Other settings</a></li>
</ul>
<script>
      $( "#showsettingsother" ).click(function() {
           $('#settingscontent').load('othersettings.html'); 
      }
</script>

My problem is the following:

  1. I upload a picture to dropzone (image1.jpg). This works fine.
  2. I upload a second picture to dropzone (image2.jpg). This works also fine.
  3. Now I click on "Other Settings" and I click back to "Company settings".
  4. The result is, that it shows image1.jpg and not image2.jpg.
  5. When I restart the browser it shows image2.jpg.

So it displays the wrong picture. Has anybody an idea what I'm doing wrong?

ubik
  • 17
  • 3
  • Does the variable called getcompanypicture store the new or the old picture path? – Arthur Z. Jan 09 '19 at 15:11
  • @Arthur Z.: getcompanypicture is the variable for the url to get the picture. It is always the same and is an PHP script to show the picture. So it is the new picture, definitly, because when I close the browser and reload the page, it shows the right picture. – ubik Jan 09 '19 at 15:57

1 Answers1

0

I belive you aren't calling back your onload picture or the function you are using to get the first image. My advise is that you encapsule the function, when you change the picture you called it back and it gets to refresh at your command.

// I'would have added a comment but I can't yet.

Danielle Lpz
  • 312
  • 3
  • 14