     @editor.setShowPrintMargin false
     session = @editor.getSession()
     session.setTabSize(2);
-    @_setMode
-    @editor.getSession().on "change", => @trigger "change"
-
+
+    @editor.getSession().on "change", =>
+      console.log "changing model"
+      @model.set code: @editor.getSession().getValue()
+
+    @model.bind "change:mode", =>
+      @editor.getSession().setMode(@modes[@model.get "mode"])
 
     # Hide the line numbering, doesn't work perfectly
     lineNumberWidth = parseInt($(".ace_scroller").css('left'))

    @saveButton.text "Save"

  save: ->
    code = @editor.getSession().getValue()
    mode = @modeEl.val()

    @model.set
      code: code,
      mode: mode,
      secret: @secret.getSecret()

    console.log "sending save #{ document.cookie }"
    @model.save null,
      success: (e) =>

      jade: new JadeMode()

    @secret = new views.Secret

    @saveButton = $ "#save"
    @saveButton.tipsy
