     dialog = if id == null then $('div.niftyDialog:last') else $("div.niftyDialog#niftyDialog-#{id}")
     options = dialog.data('options')
     if options.url?
+      if options.behavior? && behavior = this.behaviors[options.behavior]
+        behavior.beforeLoad.call(null, insertedDialog, options) if behavior.beforeLoad?
       $.ajax
         url: options.url
         success: (data)=> this.setContent(data, id)

  #
  #   behavior   => the name of a behavior set to be invoked on dialog open/close.
  #                 Behaviors can be setup using the Nifty.Dialog.addBehavior method.
  #
  open: (options={})->
    # set a dialog ID for this dialog

      console.log "Dialog could not be displayed. Invalid options passed."
      console.log options
      return false

  # Add a behaviour callback which will be executed
  addBehavior: (options)->
