title: Can't set image to jsPlumb endpoint
body: <p>I'm using jsPlumb library in my project and I have a function that changes endpoint images if they are connected. I call it when the page loads and everything works fine, but when I call it on connection event, nothing happens. Here is my code:</p>
  
  <pre><code>function changeEndpointImage(){
              var elem = $('.tableBody');   //These are my connectable elements
              for(var i=0;i&lt;elem.length;i++)
              {
                   var eps=jsPlumb.getEndpoints($(elem[i]));  //Getting endpoints for each of the connectable elements
                   for(var j=0;j&lt;eps.length;j++)
                   {
                        if(eps[j].connections.length!=0)  //Checking if any of them have connections
                             eps[j].setImage("images/styled_radiobutton.png");  //Setting another image
                   }
              }
          }
  jsPlumb.bind("connection", function(connection) {
       changeEndpointImage();
  
       //I have also tried this method commented below, but nothing.
       //connection.sourceEndpoint.setImage("images/styled_radiobutton.png");
       //connection.targetEndpoint.setImage("images/styled_radiobutton.png");
  
  });
  </code></pre>
  
  <p>I'm also trying to change endpoint images back to the first look if the connection is detached, but in this case, only the source endpoint gets changed, target remains the same:</p>
  
  <pre><code>jsPlumb.bind("connectionDetached", function(connection) {
      connection.targetEndpoint.setImage("images/rsz_styled_radiobutton.png");
      connection.sourceEndpoint.setImage("images/rsz_styled_radiobutton.png");
  });
  </code></pre>
  
  <p>What am I missing or how can I fix this problem?</p>
  
  <p>EDIT: Here is jsfiddle:</p>
  
  <p><a href="https://jsfiddle.net/vaxobasilidze/cg3hkde7/" rel="nofollow noreferrer">https://jsfiddle.net/vaxobasilidze/cg3hkde7/</a></p>
  
  <p>Drag few items to the right div, press "Add new link" and try to attach detach connections. You will see that endpoints don't change.</p>