   # given ID if one is given).
   setContent: (content, id = null)->
     dialog = if id == null then $('div.niftyDialog:last') else $("div.niftyDialog#dialog-#{id}")
-    dialog.html(content)
-    this.onSetContent(null, dialog) if this.onSetContent?
+    if dialog.length
+      dialog.html(content)
+      options = dialog.data('options')
+      if options.behavior? && behavior = this.behaviors[options.behavior]
+        behavior.onSetContent.call(null, dialog, options) if behavior.onSetContent?
+      this.onSetContent(null, dialog) if this.onSetContent?
   
   # Create a new overlay
   createOverlay: (options)->

    insertedDialog = dialogTemplate.appendTo($('body'))
    insertedDialog.css('z-index', 2000 + dialogID)
    
    overlayClass = ''
    overlayClass = 'invisible' if dialogID > 1
    theOverlay = $("<div class='niftyOverlay #{overlayClass}'></div>").insertBefore(insertedDialog).css('z-index', 2000 + dialogID - 1)
    theOverlay.fadeIn('fast')
    
      # if we have a width, set the width for the dialog
    if options.width?
      insertedDialog.css('width', "#{options.width}px")
      insertedDialog.css('margin-left', "-#{options.width / 2}px")

      insertedDialog.addClass 'loading'
      $.ajax
        url: options.url
        success: (data)=> this.displayDialog(insertedDialog, data)
    
    else if options.html?
      this.displayDialog(insertedDialog, options.html)
    
    else
      # anything else won't work
