   # 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)->

      false
    
  # Complete the opening of a dialog with the given HTML
  displayDialog: (dialog, content, options={})->
    dialog.html(content)
    dialog.fadeIn('fast')
    dialog.removeClass 'loading'
    if options.behavior? && behavior = this.behaviors[options.behavior]
      behavior.onLoad.call(null, dialog, options) if behavior.onLoad?
    options.afterLoad.call(null, dialog) if options.afterLoad?

      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
