     $moves.first().addClass('active')
     $table.removeClass('hidden')
 
+  disableEventsAndExecute: (callback) =>
+    isOutermost = !@_eventsDisabled
+
+    @_eventsDisabled = true
+    @undelegateEvents()  if isOutermost # disable events
+    callback()
+    @delegateEvents()  if isOutermost
+    @_eventsDisabled = false  if isOutermost
+
   render: =>
     @$el.html @editTemplate(window: window, speciesList: @speciesList, itemList: @itemList, pokemon: @pokemon)
     attachSelectize(@$el.find(".species_list"),

    return this

  renderPokemon: =>
    @undelegateEvents() # disable events (mostly change vevents)
    @renderSpecies()
    @renderNonStats()
    @renderStats()
    @renderMoves()
    @renderPBV()
    @delegateEvents() # re-enable events

    # Disable entering values if this is a NullPokemon
    @$el.find("input, select")

      @$(".total-pbv").text(@teamPBV).toggleClass("red", @teamPBV > maxPBV)

  renderSpecies: =>
    @disableEventsAndExecute =>
      setSelectizeValue(@$(".species_list"), @pokemon.get("name"))
      html = if @pokemon.isNull then "" else @speciesTemplate(window: window, pokemon: @pokemon)
      @$(".species-info").html(html)
      @$(".selected_shininess").toggleClass("selected", @pokemon.get('shiny') == true)

  renderNonStats: =>
    $nonStats = @$el.find(".non-stats")
