title: jquery draggable revert programmatically
body: <p>I am currently developing a calendar where activities can be drag&amp;dropped to other days.
  When an activity is dropped into a different day, I show a custom modal using durandal's dialog plugin. The problem is when an user closes the modal, the activity has to revert to its original position. When an activity is dropped the following code is called:</p>
  
  <pre><code>function showDroppedActivityModal(obj) {
      require(['modals/droppedActivityModal/droppedActivityModal', 'moment'], function(droppedActivityModal, moment) {
          droppedActivityModal.show(obj).then(function(response) {
              if(response !== false) {
                  ...
              }
              // dialog closes
              else {
                  calendarView.revertActivity.notify({ revert: true})
              }
          });
      });
  }
  </code></pre>
  
  <p>In my calendarView I implemented the revertActivity event to set revert to true but the function never re-evaluates itself but i'm able to receive the new revert value (true).</p>
  
  <pre><code>$(activity).draggable({
      revert: function() {
          var revert = false;
          self.revertActivity.attach(function(sender, args) {
              revert = args.revert;
          });
          return revert;
      }
  });
  </code></pre>
  
  <p>Custom event code:</p>
  
  <pre><code>function CalendarEvent(sender) {
      this._sender = sender;
      this._listeners = [];
  }
  
  CalendarEvent.prototype = {
      attach : function (listener) {
          this._listeners.push(listener);
      },
  
      notify : function (args) {
          var index;
          for (index = 0; index &lt; this._listeners.length; index += 1) {
              this._listeners[index](this._sender, args);
          }
      },
  
      remove : function (listener){
          this._listeners.remove(listener);
      }
  };
  
  this.revertActivity = new CalendarEvent(this);
  </code></pre>